This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ff first
#define ss second
#define pb push_back
#define SZ(x) ((int)(x).size())
#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << ": " << x << " "
#define nl cout << "\n"
#define rep(i, a, b) for(int i = (a); i <= (b); i++)
#define per(i, a, b) for(int i = (a); i >= (b); i--)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int MAXN = 1e3+100;
int N;
void initialize(int n){
N = n;
}
vector<pii> cur;
vector<int> g[MAXN];
bool used[MAXN][MAXN];
int cnt;
bool vis[MAXN];
void dfs(int v){
vis[v] = true;
for(int u : g[v]){
if(!vis[u]) dfs(u);
}
cnt++;
}
int hasEdge(int u, int v){
used[u][v] = used[v][u] = true;
rep(i, 0, N - 1) g[i].clear();
for(auto [a, b] : cur) g[a].pb(b), g[b].pb(a);
rep(i, 0, N - 1){
rep(j, i + 1, N - 1){
if(!used[i][j]){
g[i].pb(j), g[j].pb(i);
}
}
}
rep(i, 0, N - 1) vis[i] = false;
cnt = 0; dfs(0);
if(cnt == N) return 0;
cur.pb({u, v});
return 1;
}
Compilation message (stderr)
game.cpp: In function 'int hasEdge(int, int)':
game.cpp:41:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
41 | for(auto [a, b] : cur) g[a].pb(b), g[b].pb(a);
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |