답안 #621152

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
621152 2022-08-03T13:07:16 Z sword060 Zamjena (COCI18_zamjena) C++17
70 / 70
251 ms 8740 KB
#include <bits/stdc++.h>
using namespace std;
map<string,string>par;
map<string,int>mp;
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;
  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,j]:par){
    int c=(i[0]>='0'&&i[0]<='9');
    string lol=get(i);
    mp[get(lol)]+=c;
    if(mp[get(lol)]+(lol[0]>='0'&&lol[0]<='9')>1){
      cout<<"NE";
      return 0;
    }
  }
  cout<<"DA";
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 340 KB Output is correct
2 Correct 3 ms 340 KB Output is correct
3 Correct 7 ms 680 KB Output is correct
4 Correct 5 ms 792 KB Output is correct
5 Correct 7 ms 724 KB Output is correct
6 Correct 4 ms 596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 1612 KB Output is correct
2 Correct 51 ms 3188 KB Output is correct
3 Correct 79 ms 5064 KB Output is correct
4 Correct 75 ms 5944 KB Output is correct
5 Correct 251 ms 8740 KB Output is correct
6 Correct 121 ms 6076 KB Output is correct