# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
254841 | Molukhyyeh | Zamjena (COCI18_zamjena) | C++14 | 226 ms | 25980 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |