답안 #982842

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
982842 2024-05-14T19:37:58 Z vjudge1 게임 (APIO22_game) C++17
2 / 100
1 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;
        }
        if(used[t])
          continue;
        used[t]=1;
        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:41:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |     for(int i=esp; i<adj.size(); i++){
      |                    ~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 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 1 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Incorrect 1 ms 344 KB Wrong Answer[1]
12 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 1 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 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 1 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Incorrect 1 ms 344 KB Wrong Answer[1]
12 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 1 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 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 1 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Incorrect 1 ms 344 KB Wrong Answer[1]
12 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 1 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 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 1 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Incorrect 1 ms 344 KB Wrong Answer[1]
12 Halted 0 ms 0 KB -