Submission #1084336

#TimeUsernameProblemLanguageResultExecution timeMemory
1084336BlueGlaucus1Zamjena (COCI18_zamjena)C++17
Compilation error
0 ms0 KiB
#include <iostream> #include <string> #include <map> 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 (stderr)

zamjena.cpp:6:13: error: 'vector' was not declared in this scope
    6 | map<string, vector<string> > con;
      |             ^~~~~~
zamjena.cpp:4:1: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
    3 | #include <map>
  +++ |+#include <vector>
    4 | using namespace std;
zamjena.cpp:6:26: error: template argument 2 is invalid
    6 | map<string, vector<string> > con;
      |                          ^
zamjena.cpp:6:26: error: template argument 4 is invalid
zamjena.cpp:6:28: error: expected unqualified-id before '>' token
    6 | map<string, vector<string> > con;
      |                            ^
zamjena.cpp: In function 'int dfs(std::string)':
zamjena.cpp:15:23: error: 'con' was not declared in this scope; did you mean 'clone'?
   15 |     for(int i = 0; i <con[s].size();i++){
      |                       ^~~
      |                       clone
zamjena.cpp: In function 'int main()':
zamjena.cpp:47:9: error: 'con' was not declared in this scope; did you mean 'clone'?
   47 |         con[arr[i]].push_back(brr[i]);
      |         ^~~
      |         clone