#16830: C++ 參考解答


LiuTeYu (Rich_Man)

學校 : 國立臺灣大學
編號 : 63159
來源 : [220.129.41.147]
最後登入時間 :
2020-09-02 19:46:48
d517. 文字抄寫 I | From: [111.249.110.155] | 發表日期 : 2019-02-11 10:31

#include <iostream>

#include <iomanip>

#include <cstring>

#include <cctype>

#include <sstream>

#include <cstdio>

#include <cmath>

#include <stdlib.h>

#include <fstream>

#include <vector>

#include <algorithm>

#include <unordered_map>

#include <map>

#include <set>

 

typedef long long ll;

 

using namespace std;

 

int main(int argc, const char * argv[])

{

    ios_base::sync_with_stdio(false);

    cin.tie(0);

    

    ll n, count = 1;

    string reg;

    while(cin>>n)

    {

        count = 1;

        map<string ,ll> ar;

        while(n--)

        {

            cin>>reg;

            if(ar.count(reg)<=0)

            {

                ar[reg] = count;

                cout<<"New! "<<count<<'\n';

            }

            else

            {

                cout<<"Old! "<<ar[reg]<<'\n';

                count -= 1;

            }

            count += 1;

        }

    }

    return 0;

}

 
ZeroJudge Forum