problemscpp
A collection of my answers to algorithm problems in c++.
静态 Public 成员函数 | 所有成员列表
acwing::acwing1789类 参考

AcWing 1789. 牛为什么过马路 II 更多...

#include <acwing.h>

静态 Public 成员函数

static int main (istream &cin, ostream &cout)
 

详细描述

AcWing 1789. 牛为什么过马路 II

在文件 acwing.h932 行定义.

成员函数说明

◆ main()

int acwing::acwing1789::main ( istream &  cin,
ostream &  cout 
)
static

在文件 acwing.cpp2814 行定义.

2814 {
2815 char str[52];
2816 int count = 0;
2817 auto poses = vector(26, vector<int>());
2818 for(int i = 0; i < 52; i++) {
2819 char ch;
2820 cin >> ch;
2821 str[i] = ch;
2822 poses[ch - 'A'].push_back(i);
2823 }
2824 for(auto pos: poses) {
2825 auto um = unordered_map<int, int>();
2826 for(int i = pos[0] + 1; i < pos[1]; i++) {
2827 if(!um.contains(str[i])) {
2828 um.insert(pair(str[i], 1));
2829 } else {
2830 um[str[i]] = 0;
2831 }
2832 }
2833 for(const auto p: um) {
2834 if(p.second == 1) {
2835 count++;
2836 }
2837 }
2838 um = unordered_map<int, int>();
2839 for(int i = pos[1] + 1; i < pos[0] + 52; i++) {
2840 if(!um.contains(str[i % 52])) {
2841 um.insert(pair(str[i % 52], 1));
2842 } else {
2843 um[str[i % 52]] = 0;
2844 }
2845 }
2846 for(const auto p: um) {
2847 if(p.second == 1) {
2848 count++;
2849 }
2850 }
2851 }
2852 cout << count / 4;
2853 return 0;
2854 }

被这些函数引用 acwing::TEST().


该类的文档由以下文件生成: