Submission #982820

# Submission time Handle Problem Language Result Execution time Memory
982820 2024-05-14T18:44:48 Z vjudge1 Game (APIO22_game) C++17
2 / 100
4000 ms 344 KB
#include "game.h"
#include <bits/stdc++.h>
using namespace std;

int esp;
queue<int> q;
vector<vector<int>> adj;
bool used[300000];
bool si=0;

void bfs(){
    int t;
    while(!q.empty()){
        t=q.front(); q.pop();
        if(t<esp && used[t]){
          si=1;
          return;
        }
        for(int h: adj[t]){
          q.push(h);
        }
    }
}

void init(int n, int k) {
    adj.resize(n);
    esp=k;
    for(int i=1; i<esp; i++){
      adj[i-1].push_back(i);
    }
    for(int i=0; i<esp; i++)
      used[i]=1;
    si=0;
}

int add_teleporter(int u, int v) {
    adj[u].push_back(v);
    for(int i=esp; i<adj.size(); i++){
      used[i]=0;
    }
    for(int i=0; i<esp; i++){
      for(int h: adj[i]){
        if(h<esp){
          if(h>i)
            continue;
          q.push(h);
        }
        else
          q.push(h);
      }
    }
    bfs();
    return si;
}

Compilation message

game.cpp: In function 'int add_teleporter(int, int)':
game.cpp:38:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |     for(int i=esp; i<adj.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 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
# 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 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Execution timed out 4051 ms 344 KB Time limit exceeded
12 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 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Execution timed out 4051 ms 344 KB Time limit exceeded
12 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 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Execution timed out 4051 ms 344 KB Time limit exceeded
12 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 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Execution timed out 4051 ms 344 KB Time limit exceeded
12 Halted 0 ms 0 KB -