#20542: WA line:14838


fdhs109_31813 (username)

學校 : 桃園市私立復旦高級中學
編號 : 103932
來源 : [220.137.10.66]
最後登入時間 :
2024-07-15 22:26:14
d517. 文字抄寫 I | From: [220.135.156.125] | 發表日期 : 2020-02-04 20:46

#0: 100% WA (line:14838)

您的答案為: Old! 944
正確答案為: New! 2
#include<iostream>
#include<vector>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<iomanip>
#include<stack>
#include<cctype>
#include<map>
#define _ ios::sync_with_stdio(false);cin.tie(0);
#define endl '\n'
using namespace std;

int main()
{_
map<string , int> mymap;
int n;
while (cin >> n)
{
int count = 1;
for (int i = 0; i < n; i++)
{
map<string, int>::iterator iter;
string s;

cin >> s;
{
iter = mymap.find(s);
if (iter != mymap.end())
{
cout << "Old! " << iter->second << endl;
}
else
{
cout << "New! " << count << endl;
mymap[s] = count;
count++;
}
}
}
}
}
如上,用map刻出來但有bug,請大神指教
 
#20588: Re:WA line:14838


fdhs109_v0 (v0)

學校 : 桃園市私立復旦高級中學
編號 : 100758
來源 : [140.115.50.48]
最後登入時間 :
2024-05-03 10:36:01
d517. 文字抄寫 I | From: [1.34.173.108] | 發表日期 : 2020-02-10 23:13

#0: 100% WA (line:14838)

您的答案為: Old! 944
正確答案為: New! 2
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define _ ios::sync_with_stdio(false);cin.tie(0);
#define endl '\n'
using namespace std;

int main()
{_
map mymap;
int n;
while (cin >> n)
{
int count = 1;
for (int i = 0; i < n; i++)
{
map<string, int>::iterator iter;
string s;

cin >> s;
{
iter = mymap.find(s);
if (iter != mymap.end())
{
cout << "Old! " << iter->second << endl;
}
else
{
cout << "New! " << count << endl;
mymap[s] = count;
count++;
}
}
}
}
}
如上,用map刻出來但有bug,請大神指教


你沒有清除

 
ZeroJudge Forum