C Ants GYM102501

在這裏插入圖片描述
簽到

#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <cmath>

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;
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章