Submission #974633

#TimeUsernameProblemLanguageResultExecution timeMemory
974633IUA_HasinGame (APIO22_game)C++17
2 / 100
3 ms9816 KiB
#include "game.h" #include <bits/stdc++.h> #define endl "\n" #define ll long long using namespace std; const ll N = 3e5+10; ll NN, K; std::vector<ll> graph[N]; ll vis[N]; ll vis2[N]; void dfs(ll vertex){ if(vis[vertex]==1){ return; } else { vis[vertex] = 1; // cout << vertex << " "; for(auto u : graph[vertex]){ dfs(u); } return; } } void init(int n, int k) { NN = n; K = k; for(int i=0; i<=k-2; i++){ graph[i].push_back(i+1); // cout << i << " " << i+1 << endl; } } int add_teleporter(int u, int v) { graph[u].push_back(v); for(int i=0; i<=NN+5; i++){ vis[i] = 0; } dfs(0); std::vector<ll> last; for(int i=0; i<=NN+5; i++){ if(vis[i]==1){ last.push_back(i); // cout<<i<<" "; } } cout<<endl; if(u>=K && v<K){ vis2[u] = 1; // cout << u << " " << 59 << endl; } if(u>=v && u<K){ return 1; } else { for(int i=0; i<last.size(); i++){ if(vis2[last[i]]==1){ return 1; } } return 0; } }

Compilation message (stderr)

game.cpp: In function 'int add_teleporter(int, int)':
game.cpp:65:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |     for(int i=0; i<last.size(); i++){
      |                  ~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...