# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
991965 |
2024-06-03T13:05:51 Z |
nihon |
Zamjena (COCI18_zamjena) |
C++17 |
|
97 ms |
5456 KB |
#include <bits/stdc++.h>
#define N 50005
using namespace std;
struct elem
{
string s,t;
}v[N];
int n,i,j;
map<string,string> m;
bool vrf()
{
string s,t;
for(i=1;i<=n;++i)
{
s=v[i].s;
t=v[i].t;
if(s[0]<='9' && t[0]<='9' && s!=t) return 0;
else if(s[0]<='9' && t[0]>'9')
{
if(m.count(t) && m[t]!=s) return 0;
m[t]=s;
}
else if(s[0]>'9' && t[0]<='9')
{
if(m.count(s) && m[s]!=t) return 0;
m[s]=t;
}
}
for(i=1;i<=n;++i)
{
s=v[i].s;
t=v[i].t;
if(s[0]>'9' && t[0]>'9')
{
if(m.count(t) && m.count(s) && m[t]!=m[s]) return 0;
else if(m.count(t) && !m.count(s)) m[s]=m[t];
else if(!m.count(t) && m.count(s)) m[t]=m[s];
}
}
for(i=1;i<=n;++i)
{
s=v[i].s;
t=v[i].t;
if(s[0]>'9' && t[0]>'9')
{
if(m.count(t) && m.count(s) && m[t]!=m[s]) return 0;
else if(m.count(t) && !m.count(s)) m[s]=m[t];
else if(!m.count(t) && m.count(s)) m[t]=m[s];
}
}
for(i=1;i<=n;++i)
{
if(s[0]>'9' && t[0]>'9')
{
if(m[s]!=m[t]) return 0;
}
if(s[0]<='9' && t[0]>'9')
{
if(m[t]!=s) return 0;
}
if(s[0]>'9' && t[0]<='9')
{
if(m[s]!=t) return 0;
}
}
return 1;
}
int main()
{
cin>>n;
for(i=1;i<=n;++i)
{
cin>>v[i].s;
}
for(i=1;i<=n;++i)
{
cin>>v[i].t;
}
if(vrf()) cout<<"DA";
else cout<<"NE";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
3420 KB |
Output is correct |
2 |
Correct |
1 ms |
3420 KB |
Output is correct |
3 |
Correct |
1 ms |
3420 KB |
Output is correct |
4 |
Correct |
1 ms |
3420 KB |
Output is correct |
5 |
Correct |
1 ms |
3420 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
3420 KB |
Output is correct |
2 |
Correct |
1 ms |
3420 KB |
Output is correct |
3 |
Correct |
1 ms |
3420 KB |
Output is correct |
4 |
Correct |
1 ms |
3420 KB |
Output is correct |
5 |
Correct |
1 ms |
3420 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
3420 KB |
Output is correct |
2 |
Correct |
1 ms |
3432 KB |
Output is correct |
3 |
Correct |
1 ms |
3420 KB |
Output is correct |
4 |
Correct |
1 ms |
3420 KB |
Output is correct |
5 |
Correct |
1 ms |
3420 KB |
Output is correct |
6 |
Incorrect |
1 ms |
3420 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3420 KB |
Output is correct |
2 |
Correct |
2 ms |
3420 KB |
Output is correct |
3 |
Correct |
2 ms |
3420 KB |
Output is correct |
4 |
Correct |
3 ms |
3420 KB |
Output is correct |
5 |
Correct |
5 ms |
3676 KB |
Output is correct |
6 |
Correct |
3 ms |
3676 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
3416 KB |
Output is correct |
2 |
Correct |
42 ms |
4700 KB |
Output is correct |
3 |
Correct |
31 ms |
4184 KB |
Output is correct |
4 |
Correct |
33 ms |
5324 KB |
Output is correct |
5 |
Correct |
52 ms |
3824 KB |
Output is correct |
6 |
Correct |
97 ms |
5456 KB |
Output is correct |