Submission #621144

# Submission time Handle Problem Language Result Execution time Memory
621144 2022-08-03T12:58:07 Z sword060 Zamjena (COCI18_zamjena) C++17
56 / 70
279 ms 65536 KB
#include <bits/stdc++.h>
using namespace std;
map<string,vector<string>>mp;
map<string,string>par;
string get(string a){return (par.find(a)!=par.end()?par[a]=get(par[a]):a);}
void unite(string a,string b){
  a=get(a);b=get(b);
  if(a==b)return;
  for(auto j:mp[b])mp[a].push_back(j);
  mp[a].push_back(b);
  mp[b].clear();par[b]=a;
}
int main(){
  ios::sync_with_stdio(0); cin.tie(0);
  int x;cin>>x;
  string a[x],b[x];
  for(int i=0;i<x;i++)cin>>a[i];
  for(int i=0;i<x;i++)cin>>b[i],unite(a[i],b[i]);
  for(auto [i,r]:mp){
    int c=(i[0]>='0'&&i[0]<='9');
    for(auto j:r)
      if(j[0]>='0'&&j[0]<='9')c++;
    if(c>1){
      cout<<"NE";return 0;
    }
  }
  cout<<"DA";
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 316 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 2800 KB Output is correct
2 Correct 3 ms 596 KB Output is correct
3 Correct 8 ms 1356 KB Output is correct
4 Correct 25 ms 6404 KB Output is correct
5 Correct 6 ms 1180 KB Output is correct
6 Correct 6 ms 1008 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 279 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -