# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
237969 |
2020-06-09T14:23:06 Z |
tc_abd |
Zamjena (COCI18_zamjena) |
C++14 |
|
345 ms |
23320 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(int i=0;i<n;i++){
if(!dn[a[i]]){
s.clear(),dfs(a[i]);
if(s.size() > 1){
cout<<"NE"<<endl;
return 0;
}
}
if(!dn[b[i]]){
s.clear(),dfs(b[i]);
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 |
6 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 |
6 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 |
7 ms |
3456 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
3456 KB |
Output is correct |
2 |
Correct |
6 ms |
3456 KB |
Output is correct |
3 |
Correct |
6 ms |
3456 KB |
Output is correct |
4 |
Correct |
7 ms |
3456 KB |
Output is correct |
5 |
Correct |
7 ms |
3456 KB |
Output is correct |
6 |
Correct |
6 ms |
3456 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
3840 KB |
Output is correct |
2 |
Correct |
8 ms |
3712 KB |
Output is correct |
3 |
Correct |
12 ms |
4224 KB |
Output is correct |
4 |
Correct |
14 ms |
4480 KB |
Output is correct |
5 |
Correct |
18 ms |
4608 KB |
Output is correct |
6 |
Correct |
14 ms |
4352 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
34 ms |
6776 KB |
Output is correct |
2 |
Correct |
85 ms |
10064 KB |
Output is correct |
3 |
Correct |
88 ms |
11384 KB |
Output is correct |
4 |
Correct |
107 ms |
13176 KB |
Output is correct |
5 |
Correct |
345 ms |
23320 KB |
Output is correct |
6 |
Correct |
210 ms |
15480 KB |
Output is correct |