# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
218963 | 2020-04-03T10:08:39 Z | brcode | Zamjena (COCI18_zamjena) | C++14 | 52 ms | 16120 KB |
#include <iostream> #include <bits/stdc++.h> using namespace std; const int MAXN = 2e5+5; map<string,vector<string>> v1; string arr[MAXN]; string arr2[MAXN]; map<string,bool> vis; string check(string x){ char y = x[0]; if(y>='0' && y<='9'){ return x; } return ""; } string glob =""; string dfs(string curr){ vis[curr] = true; string hold = check(curr); for(auto x:v1[curr]){ if(!vis[x]){ hold+=dfs(x); } } return hold; } int main() { int n; cin>>n; int cnt = 1; for(int i=1;i<=n;i++){ cin>>arr[i]; } for(int i=1;i<=n;i++){ cin>>arr2[i]; } for(int i=1;i<=n;i++){ if(arr[i] == arr2[i]){ continue; } v1[arr[i]].push_back(arr2[i]); v1[arr2[i]].push_back(arr[i]); } for(int i=1;i<=n;i++){ if(vis[arr[i]]){ continue; } auto hold = dfs(arr[i]); for(int j=1;j<hold.size();j++){ if(hold[j]!=hold[j-1]){ cout<<"NE"<<endl; return 0; } } } cout<<"DA"<<endl; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 12 ms | 12800 KB | Output is correct |
2 | Correct | 12 ms | 12800 KB | Output is correct |
3 | Correct | 12 ms | 12800 KB | Output is correct |
4 | Correct | 12 ms | 12800 KB | Output is correct |
5 | Correct | 12 ms | 12800 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 13 ms | 12800 KB | Output is correct |
2 | Correct | 12 ms | 12800 KB | Output is correct |
3 | Correct | 13 ms | 12928 KB | Output is correct |
4 | Correct | 12 ms | 12800 KB | Output is correct |
5 | Correct | 12 ms | 12800 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 13 ms | 12800 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 13 ms | 13056 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 31 ms | 14968 KB | Output is correct |
2 | Incorrect | 52 ms | 16120 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |