Submission #677319

# Submission time Handle Problem Language Result Execution time Memory
677319 2023-01-02T19:37:05 Z Truitadepatates Cop and Robber (BOI14_coprobber) C++14
14 / 100
50 ms 1740 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){
  int m = cop%vertex2;
  r++;
  if (r == cop) return r-1;
  if ((r == cop+1 && m != 0) /*or (r = cop-1 && m != 1)*/ or (r == cop+vertex2) /*or (r == cop-vertex2)*/){
    cop = r;
    return r-1;
  }
  if ((r == cop+vertex2+1 && m != 0) or (r == cop+vertex2-1 && m != 1) or (r == cop-vertex2-1 && m != 1) or (r == cop-vertex2+1 && m != 0)){
    return cop-1;
  }
  if (r > cop){
    /*if (r <= cop+(vertex2-(m)) && m != 0){
      cop++;
      return cop-1;
    }
    if (r < cop+vertex2){
      cop--;
      return cop-1;
    }*/
    if (r <= cop+vertex2+(vertex2-(m)) && m != 0){
      cop++;
      return cop-1;
    }
    cop+=vertex2;
    return cop-1;
  }
  /*else{
    if (r > cop-(m) && m != 0){
      cop--;
      return cop-1;
    }
    if (r > cop-vertex2 && m == 0){
      cop--;
      return cop-1;
    }
    if (r > cop-vertex2){
      cop++;
      return cop-1;
    }
    if (r > cop-vertex2-(m) && m != 0){
      cop--;
      return cop-1;
    }
    if (r > cop-(2*vertex2) && m == 0){
      cop--;
      return cop-1;
    }
    cop-=vertex2;
    return cop-1;
  }*/
}

Compilation message

coprobber.cpp: In function 'int nextMove(int)':
coprobber.cpp:78:1: warning: control reaches end of non-void function [-Wreturn-type]
   78 | }
      | ^
# 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 336 KB Output is correct
2 Correct 0 ms 336 KB Output is correct
3 Correct 37 ms 1548 KB Output is correct
4 Correct 39 ms 1740 KB Output is correct
5 Correct 39 ms 1588 KB Output is correct
6 Correct 50 ms 1612 KB Output is correct
# 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 -