文章
1
粉丝
29
获赞
1
访问
125
#include<iostream>
#include<string>
#include<map>
using namespace std;
int main() {
int n, M; string s;
while (cin >> n) {
map<string, int>m;
for (int i = 0; i < n; i++) {
cin >> s; m[s] = 0;
}
cin >> M;
for (int i = 0; i < M; i++) {
cin >> s;
if (m.find(s) != m.end()) {
if (m[s] == 0) {
m[s]++; cout << "OK" << endl;
}
else cout << "REPEAT" << endl;
}
else
cout << "WRONG" << endl;
}
}
}
为什么这玩意会超时呢?
二编:好消息,超时解决了
坏消息,tmd爆内存了
#include<iostream>
#include<cstring>
#include<string>
#include<map>
using namespace std;
string read() {
string temp;
char c = getchar();
while (c != '\n')
temp += c;
return temp;
}
int main() {
int n, M; string s;
while (cin >> n) {
map<string, int>m;
for (int i = 0; i < n; i++) {
s = read();
m[s] = 0;
}
...
登录后发布评论
用输入输出加速外挂,数据量大