nyoj991

#include<bits/stdc++.h>
using namespace std;
int a[10005];
string turn (long long x)
{
    stack<char>a;
    while(x)
    {
        a.push((char)('0'+x%10));
        x/=10;
    }
    string y="";
    while(a.size())
    {
        y=y+a.top();
        a.pop();
    }
    return y;
}
int main()
{
    int t;cin>>t;
    set<string>x;
    while(t--)
    {
        string y;
        cin>>y;
        int size1=x.size();
        x.insert(y);
        int size2=x.size();
        if(size1==size2)//字符串已经有了
            {
                int q=0;
                while(size1==size2&&++q)
                {
                    size1=x.size();
                    x.insert(y+turn(q));
                    size2=x.size();
                }cout<<y+turn(q)<<endl;
            }
            else
            {
                cout<<"OK"<<endl;
            }

    }
}

猜你喜欢

转载自blog.csdn.net/qq_37252519/article/details/79340723