답안 #841910

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
841910 2023-09-02T08:25:10 Z manizare 경찰관과 강도 (BOI14_coprobber) C++14
0 / 100
39 ms 4676 KB
#include<bits/stdc++.h>
#include "coprobber.h"
 
using namespace std;
 
#define pb push_back
#define ll long long
#define F first
#define S second
#define all(s) s.begin(),s.end()
const int maxn = 502 ;
bool mark[maxn][maxn][2] , c[500][500] ; 
int nxt[maxn][maxn] , cur = 0 ,ted[maxn][maxn] ;
vector <int> G[maxn]  ;

void dfs(int vi , int vj , int k){
  mark[vi][vj][k] = 1;
  if(k == 1){
    G[vi].pb(vi) ;
    for(int i =0 ; i < G[vi].size() ; i++){
      int u = G[vi][i] ;
      if(mark[u][vj][0] == 0){
        nxt[u][vj] = vi ;
        dfs(u , vj , 0) ; 
      }
    }
    G[vi].pop_back() ;
  }else{
    for(int i =0 ; i < G[vj].size() ; i++){
      int u = G[vj][i] ;
      if(mark[vi][u][1] == 0){
        ted[vi][u]--;
        if(ted[vi][u] == 0){
          dfs(vi , u , 1) ;
        }
      }
    }
  }
}

int start(int n , bool a[500][500]){
  for(int i =0 ; i < n ; i++){
    for(int j = 0 ; j < n ; j++){
      if(a[i][j] == 1){
        G[i].pb(j) ;
      }
    }
  }
  for(int i =0 ; i < n ; i++){
    for(int j= 0 ; j < n ; j++){
      ted[i][j] = G[j].size() ;
    }
  }
  for(int i = 0 ; i < n ; i++){
    if(mark[i][i][0] == 0)
    dfs(i , i , 0) ; 
    if(mark[i][i][1] == 0)
    dfs(i , i , 1);
  }
  cur = -1 ;
  for(int i = 0 ; i < n ; i++){
    bool ok =1 ;
    for(int j =0 ; j < n ; j++){
      if(mark[i][j][0] == 0)ok =0  ;
    }
    if(ok == 1){
      cur = i ;
      break ;
    }
  }
  return cur ; 
}
int nextMove(int r){
  cur = nxt[cur][r] ;
  return cur ;  
}

Compilation message

coprobber.cpp: In function 'void dfs(int, int, int)':
coprobber.cpp:20:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |     for(int i =0 ; i < G[vi].size() ; i++){
      |                    ~~^~~~~~~~~~~~~~
coprobber.cpp:29:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |     for(int i =0 ; i < G[vj].size() ; i++){
      |                    ~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 356 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 39 ms 4676 KB Output is correct
5 Incorrect 11 ms 3352 KB the situation repeated
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB the situation repeated
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Incorrect 0 ms 344 KB the situation repeated
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 356 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 39 ms 4676 KB Output is correct
5 Incorrect 11 ms 3352 KB the situation repeated
6 Halted 0 ms 0 KB -