답안 #982814

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
982814 2024-05-14T18:33:57 Z vjudge1 게임 (APIO22_game) C++17
0 / 100
1 ms 344 KB
#include "game.h"
#include <bits/stdc++.h>
using namespace std;

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

void dfs(int node, int ini){
    if(node<=ini){
      si=1;
      return;
    }
    if(used[node])
      return;
    used[node]=1;
    for(int h: adj[node]){
      dfs(h, ini);
    }
}

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

int add_teleporter(int u, int v) {
    adj[u].push_back(v);
    for(int i=0; i<adj.size(); i++)
      used[i]=0;
    for(int i=0; i<esp; i++){
      for(int j=0; j<adj.size(); j++)
        used[j]=0;
        dfs(i, i);
    }
    
    return si;
}

Compilation message

game.cpp: In function 'int add_teleporter(int, int)':
game.cpp:34:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |     for(int i=0; i<adj.size(); i++)
      |                  ~^~~~~~~~~~~
game.cpp:37:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |       for(int j=0; j<adj.size(); j++)
      |                    ~^~~~~~~~~~~
game.cpp:37:7: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   37 |       for(int j=0; j<adj.size(); j++)
      |       ^~~
game.cpp:39:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   39 |         dfs(i, i);
      |         ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Wrong Answer[1]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Wrong Answer[1]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Wrong Answer[1]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Wrong Answer[1]
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Wrong Answer[1]
3 Halted 0 ms 0 KB -