Submission #718641

#TimeUsernameProblemLanguageResultExecution timeMemory
718641filipmihovMostovi (COI14_mostovi)C++98
0 / 100
14 ms11552 KiB
#include <bits/stdc++.h> using namespace std; bool l, visited[100002]; vector <vector <int> > v(100005); vector <int> izbrisi (vector <int> r, int x) { vector <int> t; for (int i=0; i<r.size(); i++) if (r[i] != x) t.push_back(r[i]); return t; } void dfs (int teme, int kraj) { if (teme == kraj) { l = true; return; } visited[teme] = true; for (int i=0; i<v[teme].size(); i++) if (visited[v[teme][i]] == false) { dfs(v[teme][i], kraj); if (l==true) return; } } int main() { int n, m; cin >> n >> m; for (int i=1; i<n; i++) v[i].push_back(i+1); for (int j=n+1; j<=2*n; j++) v[j].push_back(j-1); while (m--) { char x; cin >> x; if (x=='A') { int a,b; cin >> a >> b; v[a].push_back(b); v[b].push_back(a); } if (x=='B') { int a,b; cin >> a >> b; if (a < b) v[a] = izbrisi(v[a], b); else v[b] = izbrisi(v[b], a); } if (x=='Q') { int a,b; cin >> a >> b; l = false; memset(visited,0,sizeof(visited)); dfs(a, b); if (l==true) cout << "DA" << endl; else cout << "NE" << endl; } } return 0; }

Compilation message (stderr)

mostovi.cpp: In function 'std::vector<int> izbrisi(std::vector<int>, int)':
mostovi.cpp:11:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |     for (int i=0; i<r.size(); i++)
      |                   ~^~~~~~~~~
mostovi.cpp: In function 'void dfs(int, int)':
mostovi.cpp:28:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |     for (int i=0; i<v[teme].size(); i++)
      |                   ~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...