Submission #254841

# Submission time Handle Problem Language Result Execution time Memory
254841 2020-07-30T17:42:00 Z Molukhyyeh Zamjena (COCI18_zamjena) C++14
70 / 70
226 ms 25980 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end() 

int const N = 200001;
int n, a[N], b[N], have;
string x[N], y[N];
map<string, int> mp, vs;
map<string, vector<string> > g;

void go(string cur){
     vs[cur] = true;
     if(cur[0]-'0' >= 0 && cur[0]-'0' <= 9)++have;
     if(have > 1){puts("NE"); exit(0);}
     for(auto i: g[cur]){
         if(vs[i])continue;
         go(i);
     }
}

int main(){
    scanf("%d", &n);
    for(int i = 0; i<n; ++i){
        cin >> x[i];
        if(x[i][0]-'0' >= 0 && x[i][0]-'0' <= 9){
            stringstream ss; 
            ss << x[i];
            ss >> a[i];
        }
        else a[i] = -1;
    }
    for(int i = 0; i<n; ++i){
        cin >> y[i];
        if(y[i][0]-'0' >= 0 && y[i][0]-'0' <= 9){
            stringstream ss; 
            ss << y[i];
            ss >> b[i];
        }
        else b[i] = -1;
    }
    for(int i = 0; i<n; ++i){
       g[x[i]].push_back(y[i]);
       g[y[i]].push_back(x[i]);
    }
    for(int i = 0; i<n; ++i){
       have = 0;
       if(!vs[x[i]])go(x[i]);
    }
    puts("DA");
}

Compilation message

zamjena.cpp: In function 'int main()':
zamjena.cpp:23:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 11 ms 12800 KB Output is correct
2 Correct 9 ms 12800 KB Output is correct
3 Correct 8 ms 12800 KB Output is correct
4 Correct 9 ms 12800 KB Output is correct
5 Correct 9 ms 12800 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 12800 KB Output is correct
2 Correct 13 ms 12800 KB Output is correct
3 Correct 12 ms 12800 KB Output is correct
4 Correct 9 ms 12800 KB Output is correct
5 Correct 7 ms 12800 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 12800 KB Output is correct
2 Correct 7 ms 12916 KB Output is correct
3 Correct 8 ms 12800 KB Output is correct
4 Correct 8 ms 12800 KB Output is correct
5 Correct 8 ms 12800 KB Output is correct
6 Correct 8 ms 12800 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 13056 KB Output is correct
2 Correct 9 ms 13056 KB Output is correct
3 Correct 13 ms 13440 KB Output is correct
4 Correct 15 ms 13568 KB Output is correct
5 Correct 17 ms 13696 KB Output is correct
6 Correct 17 ms 13440 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 34 ms 15224 KB Output is correct
2 Correct 71 ms 17400 KB Output is correct
3 Correct 63 ms 18680 KB Output is correct
4 Correct 103 ms 20788 KB Output is correct
5 Correct 226 ms 25980 KB Output is correct
6 Correct 152 ms 22008 KB Output is correct