Submission #39329

#TimeUsernameProblemLanguageResultExecution timeMemory
39329UncleGrandpa925Amusement Park (JOI17_amusement_park)C++14
59 / 100
32 ms7020 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], child[NMAX + 5]; vector<vector<int> > a(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; } bool cmp(int u, int v) { return child[u] < child[v]; } void dfs(int u, int root, int Z, int from) { if (mark[Lab(u)] == -1) { mark[Lab(u)] = Z; rem--; if (rem == 0) throw 1; } visited[u] = true; sort(a[u].begin(), a[u].end(), cmp); for (int i = 0; i < a[u].size(); i++) { int v = a[u][i]; if (v == par[u] || visited[v]) continue; dfs(v, root, Move(v), from); } 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; while (child[P] < 60) { last = Move(par[P]); P = par[P]; } try { dfs(P, P, last, P); } catch (...) { for (int i = 0; i < 60; i++) { if (mark[i] == 1) ret += (1LL << i); } } return ret; }

Compilation message (stderr)

Ioi.cpp: In function 'void dfs(int, int, int, int)':
Ioi.cpp:64: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...