Submission #39330

#TimeUsernameProblemLanguageResultExecution timeMemory
39330UncleGrandpa925Amusement Park (JOI17_amusement_park)C++14
80 / 100
34 ms6864 KiB
#include "Joi.h" #include <bits/stdc++.h> using namespace std; #define sp ' ' #define endl '\n' #define fi first #define se second #define mp make_pair #define bit(x,y) ((x>>(y))&1LL) #define NMAX 10000 #define MMAX 20000 #define MOVEMAX 20000 struct dsu { int par[NMAX + 5]; dsu() { for (int i = 0; i < NMAX; i++) par[i] = i; } int find(int x) { if (par[x] == x) return x; return par[x] = find(par[x]); } void uni(int x, int y) { x = find(x); y = find(y); if (x != y) par[x] = y; } } d; int Time = 0; int sta[NMAX + 5], par[NMAX + 5]; vector<vector<int> > a(NMAX + 5); void dfs(int u, int p) { sta[u] = ++Time; for (auto v : a[u]) { if (v == p) continue; par[v] = u; dfs(v, u); } } void makeTree(int N, int M, int A[], int B[]) { for (int i = 0; i < M; i++) { if (d.find(A[i]) != d.find(B[i])) { d.uni(A[i], B[i]); a[A[i]].push_back(B[i]); a[B[i]].push_back(A[i]); } } dfs(0, 0); } // end of the common part void Joi(int N, int M, int A[], int B[], long long X, int T) { makeTree(N, M, A, B); for (int i = 0; i < N; i++) MessageBoard(i, bit(X, sta[i] % 60)); }
#include "Ioi.h" #include <bits/stdc++.h> using namespace std; #define sp ' ' #define endl '\n' #define fi first #define se second #define mp make_pair #define bit(x,y) ((x>>(y))&1LL) #define NMAX 10000 #define MMAX 20000 #define MOVEMAX 20000 struct dsu { int par[NMAX + 5]; dsu() { for (int i = 0; i < NMAX; i++) par[i] = i; } int find(int x) { if (par[x] == x) return x; return par[x] = find(par[x]); } void uni(int x, int y) { x = find(x); y = find(y); if (x != y) par[x] = y; } } d; int Time = 0; int sta[NMAX + 5], par[NMAX + 5]; vector<vector<int> > a(NMAX + 5); int child[NMAX + 5]; int mark[60]; bool visited[NMAX + 5]; int rem; void dfs(int u, int p) { sta[u] = ++Time; child[u] = 1; for (auto v : a[u]) { if (v == p) continue; par[v] = u; dfs(v, u); child[u] += child[v]; } } void makeTree(int N, int M, int A[], int B[]) { for (int i = 0; i < M; i++) { if (d.find(A[i]) != d.find(B[i])) { d.uni(A[i], B[i]); a[A[i]].push_back(B[i]); a[B[i]].push_back(A[i]); } } dfs(0, 0); } int Lab(int u) { return sta[u] % 60; } void sfd(int u, const int root, int Z) { if (mark[Lab(u)] == -1) { mark[Lab(u)] = Z; rem--; } if (rem == 0) return; visited[u] = true; for (int i = 0; i < a[u].size(); i++) { int v = a[u][i]; if (v == par[u] || visited[v]) continue; sfd(v, root, Move(v)); if (rem == 0) return; } if (u != root) { Move(par[u]); } } long long Ioi(int N, int M, int A[], int B[], int P, int V, int T) { long long ret = 0; makeTree(N, M, A, B); memset(mark, -1, sizeof(mark)); rem = 60; int last = V; mark[Lab(P)] = last; rem--; while (child[P] < 60 && rem != 0) { P = par[P]; last = Move(P); if (mark[Lab(P)] == -1) { mark[Lab(P)] = last; rem--; } } sfd(P, P, last); for (int i = 0; i < 60; i++) { if (mark[i] == 1) ret += (1LL << i); } return ret; }

Compilation message (stderr)

Ioi.cpp: In function 'void sfd(int, int, int)':
Ioi.cpp:60:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < a[u].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...