Submission #677301

# Submission time Handle Problem Language Result Execution time Memory
677301 2023-01-02T19:06:02 Z Truitadepatates Cop and Robber (BOI14_coprobber) C++14
0 / 100
1 ms 464 KB
#include <bits/stdc++.h>
using namespace std;

//subtask 2

vector<int> adj[501];
int cop = 1;
int vertex2;

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){
        adj[i+1].push_back(j+1);
      }
    }
  }
  for (int i = 2; i < n; i++){
    if (adj[i].size() == 2) {
      vertex2 = i;
      break;
    }
  }
  return 0;
}

int nextMove(int r){
  r++;
  if (r == cop) return r-1;
  if ((r == cop+1 && cop%vertex2 != 0) or (r = cop-1 && cop%vertex2 != 1) or (r == cop+vertex2) or (r == cop-vertex2)){
    cop = r;
    return r-1;
  }
  if ((r == cop+vertex2+1 && cop%vertex2 != 0) or (r == cop+vertex2-1 && cop%vertex2 != 1) or (r == cop-vertex2-1 && cop%vertex2 != 1) or (r == cop-vertex2+1 && cop%vertex2 != 0)){
    return cop-1;
  }
  if (r > cop){
    if (r <= cop+(vertex2-(cop%vertex2))){
      cop++;
      return cop-1;
    }
    if (r < cop+vertex2){
      cop--;
      return cop-1;
    }
    if (r <= cop+vertex2+(vertex2-(cop%vertex2))){
      cop++;
      return cop-1;
    }
    cop+=vertex2;
    return cop-1;
  }
  else{
    if (r > cop-(cop%vertex2)){
      cop--;
      return cop-1;
    }
    if (r > cop-vertex2){
      cop++;
      return cop-1;
    }
    if (r > cop-vertex2-(cop%vertex2)){
      cop--;
      return cop-1;
    }
    cop-=vertex2;
    return cop-1;
  }
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 464 KB Execution killed with signal 8
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Incorrect 0 ms 336 KB the situation repeated
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 464 KB Execution killed with signal 8
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 464 KB Execution killed with signal 8
2 Halted 0 ms 0 KB -