# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1084337 | 2024-09-06T00:11:16 Z | BlueGlaucus1 | Zamjena (COCI18_zamjena) | C++17 | 139 ms | 16084 KB |
#include <iostream> #include <string> #include <map> #include <vector> using namespace std; map<string, vector<string> > con; map<string, bool> visited; int dfs(string s){ int curr_val = 0; if(isdigit(s[0])){ curr_val = stoi(s); } visited[s] = 1; for(int i = 0; i <con[s].size();i++){ string val = con[s][i]; if(visited[val]){ continue; } int cor = dfs(val); if(cor == -1){ return -1; } else if (cor ==0){ continue; } else if (curr_val==0){ curr_val = cor; }else if (curr_val!=cor){ return -1; } } return curr_val; } int main(){ int n; cin >> n; string arr[n]; string brr[n]; for(int i =0; i <n;i++){ cin >> arr[i]; } for(int i =0; i <n;i++){ cin >> brr[i]; } for(int i =0; i <n;i++){ con[arr[i]].push_back(brr[i]); con[brr[i]].push_back(arr[i]); } for(int i = 0; i <n;i++){ if(!visited[arr[i]]){ int g = dfs(arr[i]); if(g==-1){ cout <<"NE"; return 0; } } } cout << "DA"<<'\n'; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 344 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 600 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 344 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 604 KB | Output is correct |
2 | Correct | 1 ms | 604 KB | Output is correct |
3 | Correct | 3 ms | 1116 KB | Output is correct |
4 | Correct | 4 ms | 1116 KB | Output is correct |
5 | Correct | 6 ms | 1372 KB | Output is correct |
6 | Correct | 5 ms | 1104 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 23 ms | 3420 KB | Output is correct |
2 | Correct | 45 ms | 5968 KB | Output is correct |
3 | Correct | 35 ms | 7764 KB | Output is correct |
4 | Correct | 55 ms | 10324 KB | Output is correct |
5 | Correct | 139 ms | 16084 KB | Output is correct |
6 | Correct | 110 ms | 12096 KB | Output is correct |