# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
237974 |
2020-06-09T14:27:07 Z |
tc_abd |
Zamjena (COCI18_zamjena) |
C++14 |
|
354 ms |
22776 KB |
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define It it=se.begin();it!=se.end();it++
#define mem(dp,i) memset(dp,i,sizeof(dp))
#define all(x) begin(x),end(x)
#define unmap unordered_map
#define pii pair<int,int>
#include <bits/stdc++.h>
#define pll pair<ll,ll>
#define vll vector<ll>
#define vi vector<int>
#define ld long double
#define ll long long
#define pb push_back
#define sh short int
#define mid (l+r)/2
#define S second
#define F first
#define sqr 447
using namespace std;
const int inf = 1e9+9;
const int mod = 1e9+7;
const ld pai=acos(-1);
int n;
string a[50009];
string b[50009];
set < string > s,se;
map < string , bool > dn;
map < string , bool > done;
map < string , string > val;
map < string , vector < string > > v;
void dfs(string node){
dn[node] = 1;
if(done[node]) s.insert(val[node]);
for(auto u:v[node]){
if(!dn[u]) dfs(u);
}
}
int main(){
fast,cin>>n;
for(int i=0;i<n;i++) cin>>a[i];
for(int i=0;i<n;i++) cin>>b[i];
for(int i=0;i<n;i++){
int id1 = a[i][0]-'0';
int id2 = b[i][0]-'0';
if(id1 < 0 || id1 > 9){
se.insert(a[i]);
if(id2 < 0 || id2 > 9){
se.insert(b[i]);
v[a[i]].pb(b[i]);
v[b[i]].pb(a[i]);
}
else{
if(done[a[i]] && val[a[i]] != b[i]){
cout<<"NE"<<endl;
return 0;
}
done[a[i]] = 1,val[a[i]] = b[i];
}
}
else if(id2 < 0 || id2 > 9){
se.insert(b[i]);
if(done[b[i]] && val[b[i]] != a[i]){
cout<<"NE"<<endl;
return 0;
}
done[b[i]] = 1,val[b[i]] = a[i];
}
}
for(auto it=se.begin();it!=se.end();it++){
if(dn[*it]) continue;
s.clear(),dfs(*it);
if(s.size() > 1){
cout<<"NE"<<endl;
return 0;
}
}
cout<<"DA"<<endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
3456 KB |
Output is correct |
2 |
Incorrect |
7 ms |
3456 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
3456 KB |
Output is correct |
2 |
Correct |
8 ms |
3456 KB |
Output is correct |
3 |
Correct |
7 ms |
3456 KB |
Output is correct |
4 |
Correct |
6 ms |
3456 KB |
Output is correct |
5 |
Correct |
7 ms |
3456 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
3456 KB |
Output is correct |
2 |
Correct |
7 ms |
3456 KB |
Output is correct |
3 |
Correct |
6 ms |
3456 KB |
Output is correct |
4 |
Correct |
6 ms |
3456 KB |
Output is correct |
5 |
Correct |
6 ms |
3456 KB |
Output is correct |
6 |
Correct |
6 ms |
3456 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
3840 KB |
Output is correct |
2 |
Correct |
8 ms |
3712 KB |
Output is correct |
3 |
Correct |
14 ms |
4480 KB |
Output is correct |
4 |
Correct |
12 ms |
4352 KB |
Output is correct |
5 |
Correct |
16 ms |
4480 KB |
Output is correct |
6 |
Correct |
12 ms |
4096 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
6136 KB |
Output is correct |
2 |
Correct |
102 ms |
9720 KB |
Output is correct |
3 |
Correct |
174 ms |
14108 KB |
Output is correct |
4 |
Correct |
184 ms |
14456 KB |
Output is correct |
5 |
Correct |
354 ms |
22776 KB |
Output is correct |
6 |
Correct |
210 ms |
14968 KB |
Output is correct |