Submission #841902

# Submission time Handle Problem Language Result Execution time Memory
841902 2023-09-02T08:15:53 Z manizare Cop and Robber (BOI14_coprobber) C++14
0 / 100
60 ms 26792 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] , ans[maxn][maxn][2] , c[500][500] ; 
int nxt[maxn][maxn] , cur = 0;
vector <int> G[maxn]  ;
 
bool dfs(int vi , int vj , int k){
  if(mark[vi][vj][k] == 1)return ans[vi][vj][k] ;
  mark[vi][vj][k] =1 ;
  if(vi==vj){
    ans[vi][vj][k] = 1;
    return 1;
  }
  if(k == 0){
    if(dfs(vi , vj, 1) == 1){
      ans[vi][vj][0] = 1;
      nxt[vi][vj] = vi ;
    }
    for(int i = 0 ; i < G[vi].size() ; i++){
      int u = G[vi][i] ;
      if(dfs(u,vj,1) == 1){
        nxt[vi][vj] = u ;
        ans[vi][vj][0] = 1 ;
      }
    }
  }else{
    ans[vi][vj][1] = 1 ;
    for(int i= 0 ; i < G[vj].size() ; i++){
      int u = G[vj][i] ;
      if(dfs(vi , u, 0) == 0){
        ans[vi][vj][1] =0  ;
      }
    }
  }
  return ans[vi][vj][k] ;
}
 
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++){
      for(int k = 0 ; k  <2;k ++){
        dfs(i , j , k) ;
      }
    }
  }
  cur = -1 ;
  for(int i = 0 ; i < n ; i++){
    bool ok =1 ;
    for(int j =0 ; j < n ; j++){
      if(ans[i][j][0] == 0)ok =0  ;
    }
    if(ok == 1){
      cur = i ;
      break ;
    }
  }
  if(cur == -1){
    while(1){
      
    }
  } 
  return cur ; 
}
int nextMove(int r){
  cur = nxt[cur][r] ;
  return cur ;  
}

Compilation message

coprobber.cpp: In function 'bool dfs(int, int, int)':
coprobber.cpp:28:23: 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 < G[vi].size() ; i++){
      |                     ~~^~~~~~~~~~~~~~
coprobber.cpp:37:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |     for(int i= 0 ; i < G[vj].size() ; i++){
      |                    ~~^~~~~~~~~~~~~~
# Verdict Execution time Memory 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 60 ms 26792 KB the situation repeated
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB the situation repeated
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Incorrect 1 ms 344 KB the situation repeated
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 60 ms 26792 KB the situation repeated
5 Halted 0 ms 0 KB -