Submission #254841

#TimeUsernameProblemLanguageResultExecution timeMemory
254841MolukhyyehZamjena (COCI18_zamjena)C++14
70 / 70
226 ms25980 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...