Submission #792943

# Submission time Handle Problem Language Result Execution time Memory
792943 2023-07-25T11:26:56 Z Trisanu_Das Zamjena (COCI18_zamjena) C++17
70 / 70
124 ms 16028 KB
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
 
int n, cond;
string a[50005], b[50005];
map<string, vector<string> > adj;
set<string> vis;
 
void dfs(string u){
  vis.insert(u);
  cond += isdigit(u[0]);
  for(auto v : adj[u]) if(vis.find(v) == vis.end()) dfs(v);
}
 
int main(){
  int n; cin >> n;
  for(int i = 0; i < n; i++) cin >> a[i];
  for(int i = 0; i < n; i++) cin >> b[i];
  for(int i = 0; i < n; i++){
    if(a[i] != b[i]){
      adj[a[i]].pb(b[i]);
      adj[b[i]].pb(a[i]);
    }
  }
  for(auto u : adj){
    if(vis.find(u.first) == vis.end()){
      cond = 0; dfs(u.first);
      if(cond > 1){
        cout << "NE\n"; return 0;
      }
    }
  }
  cout << "DA\n";
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3412 KB Output is correct
2 Correct 2 ms 3412 KB Output is correct
3 Correct 1 ms 3412 KB Output is correct
4 Correct 2 ms 3412 KB Output is correct
5 Correct 1 ms 3440 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3412 KB Output is correct
2 Correct 2 ms 3412 KB Output is correct
3 Correct 2 ms 3412 KB Output is correct
4 Correct 2 ms 3412 KB Output is correct
5 Correct 2 ms 3412 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3440 KB Output is correct
2 Correct 2 ms 3440 KB Output is correct
3 Correct 2 ms 3440 KB Output is correct
4 Correct 2 ms 3412 KB Output is correct
5 Correct 2 ms 3440 KB Output is correct
6 Correct 2 ms 3412 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 3668 KB Output is correct
2 Correct 5 ms 3568 KB Output is correct
3 Correct 4 ms 3924 KB Output is correct
4 Correct 4 ms 4052 KB Output is correct
5 Correct 8 ms 4180 KB Output is correct
6 Correct 4 ms 3888 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 5460 KB Output is correct
2 Correct 32 ms 7740 KB Output is correct
3 Correct 34 ms 9008 KB Output is correct
4 Correct 43 ms 10104 KB Output is correct
5 Correct 124 ms 16028 KB Output is correct
6 Correct 84 ms 12052 KB Output is correct