C Ants GYM102501

C Ants GYM102501_第1张图片
签到

#include 
#include 
#include 
#include 
#include 
#include 
#include 

using namespace std;

const int maxn = 1e6 + 7;

map<string,int>mp;
int vis[maxn];

int trans(string now) {
    int ans = 0;
    for(int i = 0;i < now.size();i++) {
        ans = ans * 10 + now[i] - '0';
    }
    return ans;
}

int main() {
    ios::sync_with_stdio(false);
    int n;cin >> n;
    for(int i = 1;i <= n;i++) {
        string tmp;cin >> tmp;
        if(tmp[0] == '-') continue;
        if(tmp.size() > 7) continue;
        int now = trans(tmp);
        if(now > n + 1) continue;
        vis[now] = 1;
    }
    for(int i = 0;i <= n;i++) {
        if(!vis[i]) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

你可能感兴趣的:(#,gym)