제출 #1053388

#제출 시각아이디문제언어결과실행 시간메모리
1053388SzymonKrzywda경찰관과 강도 (BOI14_coprobber)C++17
16 / 100
23 ms2720 KiB
#include <bits/stdc++.h> using namespace std; vector<int> graf[500]; int odl[500][500]; int akt_pos = 0; ///cykle stack<int> stosik; int akt_v; int akt_wynik; int odwiedzone_2[500]; void recursion(int p, int w, int glebokosc){ odwiedzone_2[w] = true; for (int s : graf[w]){ if (p!=s){ if (odwiedzone_2[w]==false) recursion(w,s,glebokosc+1); else if (akt_v==w) akt_wynik = max(akt_wynik,glebokosc); } } odwiedzone_2[w] = false; } int start(int n,bool A[][500] ){ for (int i=0; i<n; i++){ for (int j=0; j<n; j++){ if (A[i][j]) graf[i].push_back(j); } } for (int i=0; i<n; i++){ akt_wynik = 0; for (int j=0; j<n; j++) odwiedzone_2[j] = false; recursion(-1,i,1); if (akt_wynik>4) return -1; } for (int i=0; i<n; i++){ vector<bool> odwiedzone(n,false); queue<pair<int,int>> kolejka; odwiedzone[i] = true; kolejka.push({0,i}); while (!kolejka.empty()){ int v = kolejka.front().second; int val = kolejka.front().first; kolejka.pop(); odl[i][v] = val; for (int s : graf[v]){ if (!odwiedzone[s]){ odwiedzone[s] = true; kolejka.push({val+1,s}); } } } } return 0; } int nextMove(int R){ int akt_k,akt_m=1e8; for (int s : graf[akt_pos]){ int maxi=0; for (int s_2 : graf[R]){ maxi = max(maxi,odl[s][s_2]); } if (maxi < akt_m){ akt_k = s; akt_m = maxi; } } akt_pos = akt_k; return akt_k; }

컴파일 시 표준 에러 (stderr) 메시지

coprobber.cpp: In function 'int nextMove(int)':
coprobber.cpp:100:12: warning: 'akt_k' may be used uninitialized in this function [-Wmaybe-uninitialized]
  100 |     return akt_k;
      |            ^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...