| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 855696 | vjudge1 | Zamjena (COCI18_zamjena) | C++17 | 43 ms | 8372 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#ifndef Local
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#endif
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define lim 100000
using namespace std;
const int mod=1000000007ll;
bool isdig(string s){
for(int i=0;i<s.size();i++){
switch (s[i])
{
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
break;
default:
return 0;
}
}
return 1;
}
unordered_map<string,string>parent;
string find(string i){
if(parent[i]==i){
return i;
}
return parent[i]=find(parent[i]);
}
void unite(string&i,string&j){
string x=find(i),y=find(j);
if(isdig(x)){
parent[y]=x;
}else{
parent[x]=y;
}
}
void solve(){
int n;
cin>>n;
string s1[n],s2[n];
for(int i=0;i<n;i++){
cin>>s1[i];
if(!parent.count(s1[i]))parent[s1[i]]=s1[i];
}
for(int i=0;i<n;i++){
cin>>s2[i];
if(!parent.count(s2[i]))parent[s2[i]]=s2[i];
}
for(int i=0;i<n;i++){
unite(s1[i],s2[i]);
//cerr<<s1[i]<<" "<<s2[i]<<"\n";
//cerr<<find(s1[i])<<" "<<find(s2[i])<<"\n";
//cerr<<"\n";
}//cerr<<"\n";
for(auto p:parent){
if(isdig(p.first)&&find(p.first)!=p.first){
cout<<"NE\n";
return;
}//else cerr<<p.first<<" "<<find(p.first)<<"\n";
}
cout<<"DA\n";
}
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);
#ifdef Local
freopen("in","r",stdin);
freopen("out","w",stdout);
#endif
int t=1;
//cin>>t;
while (t--)
{
solve();
}
}컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
