제출 #1014166

#제출 시각아이디문제언어결과실행 시간메모리
1014166AmirAli_H1게임 (IOI14_game)C++17
100 / 100
253 ms38484 KiB
// In the name of Allah #include <bits/stdc++.h> #include "game.h" using namespace std; typedef long long int ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef complex<ld> cld; #define all(x) (x).begin(),(x).end() #define len(x) ((ll) (x).size()) #define F first #define S second #define pb push_back #define sep ' ' #define endl '\n' #define Mp make_pair #define kill(x) cout << x << '\n', exit(0) #define set_dec(x) cout << fixed << setprecision(x); #define file_io(x,y) freopen(x, "r", stdin); freopen(y, "w", stdout); mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const int maxn = 1500 + 4; int n; int M[maxn][maxn]; vector<int> adj[maxn]; bool mark[maxn]; int val[maxn]; vector<int> ls; void initialize(int Nx) { n = Nx; mark[0] = 1; ls.pb(0); for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) M[i][j] = -1; } } int hasEdge(int u, int v) { if (!mark[u]) swap(u, v); if (M[u][v] != -1) return M[u][v]; adj[u].pb(v); adj[v].pb(u); if (!mark[u] && !mark[v]) { M[u][v] = M[v][u] = 0; return M[u][v]; } else if (mark[u] && mark[v]) { val[u]++; val[v]++; M[u][v] = M[v][u] = 0; return M[u][v]; } val[v]++; if (val[v] == len(ls)) { M[u][v] = M[v][u] = 1; mark[v] = 1; ls.pb(v); for (int r : adj[v]) val[r]++; } else { M[u][v] = M[v][u] = 0; } return M[u][v]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...