제출 #38546

#제출 시각아이디문제언어결과실행 시간메모리
38546Waschbar경찰관과 강도 (BOI14_coprobber)C++14
16 / 100
46 ms2296 KiB
#include <bits/stdc++.h> #include "coprobber.h" //using namespace std; //const int MAX_N = 15; int n, nn, mm, s, timer, tp, tpp; int p[1000], tin[1000], tout[1000]; bool ind; bool g[1000][1000]; bool used[1000]; void DFS(int f, int pr) { p[f] = pr; tin[f] = ++timer; used[f] = 1; for(int i = 0; i < n; i++) { if(!g[f][i] || i == pr) continue; if(used[i]) { ind = 1; continue;} DFS(i,f); } tout[f] = timer; } bool upper(int x, int y) { //cout << x << " - " << tin[x] << " " << tout[x] << " | " << y << " - " << tin[y] << " " << tout[y] << endl; return ((tin[x] <= tin[y]) && (tout[x] >= tout[y])); } int start(int N, bool A[MAX_N][MAX_N]) { n = N; s = 0; for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) g[i][j] = A[i][j]; DFS(0, -1); if(!ind) tp = 1; else tp = 2; if(tp == 1) return 0; if(tp == 2) { mm = 0; while(g[mm][mm+1]) mm++; mm++; nn = n/mm; if(nn == 2) {tpp = 1; s=0; return s;} if(mm == 2) {tpp = 2; s=0; return s;} if(nn == 3) {tpp = 3; s=mm+1; return s;} if(mm == 3) {tpp = 4; s=1; return s;} return -1; } } int nextMove(int R) { if(tp == 1){ for(int i = 0; i < n; i++) { //cout << s << " " << i << " " << g[s][i] << endl; if(!g[s][i] || i == p[s]) continue; if(upper(i,R)) {s = i; return i;} } return -1; } if(tp == 2) { if(tpp == 1) { if(g[s][R]) return R; s++; return s; } if(tpp == 2) { if(g[s][R]) return R; s+=2; return s; } if(tpp == 3) { if(g[s][R]) return R; s++; return s; } if(tpp == 4) { if(g[s][R]) return R; s+=3; return s; } } } /* bool v[MAX_N][MAX_N]; int main() { int nn; cin >> nn; for(int i = 1; i < nn; i++) { int x, y; cin >> x >> y; v[x][y] = v[y][x] = 1; } cout << ":: " << start(nn,v) << endl; while(true){ int x; cin >> x; cout <<":: " << nextMove(x) << endl; } }*/

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

coprobber.cpp: In function 'int start(int, bool (*)[500])':
coprobber.cpp:56:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
coprobber.cpp: In function 'int nextMove(int)':
coprobber.cpp:89:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...