Submission #108532

#TimeUsernameProblemLanguageResultExecution timeMemory
108532E869120Amusement Park (JOI17_amusement_park)C++14
82 / 100
1063 ms4300 KiB
#include "Joi.h" #include <iostream> #include <vector> using namespace std; vector<int>G[10009]; int col[10009], v[20009], cnts; void make_ransuu1(int B) { for (int i = 0; i < B; i++) v[i] = i; unsigned long long x = 1640; for (int i = 0; i < 1000000; i++) { x ^= x << 13; x ^= x >> 7; x ^= x << 17; int u1 = (x % B); x ^= x << 13; x ^= x >> 7; x ^= x << 17; int u2 = (x % B); swap(v[u1], v[u2]); } } void dfs(int pos) { if (col[pos] >= 0) return; col[pos] = cnts % 60; cnts++; for (int i = 0; i < G[pos].size(); i++) dfs(G[pos][i]); } void Joi(int N, int M, int A[], int B[], long long X, int T) { make_ransuu1(M); for (int i = 0; i < M; i++) { G[A[v[i]]].push_back(B[v[i]]); G[B[v[i]]].push_back(A[v[i]]); } for (int i = 0; i < N; i++) col[i] = -1; dfs(0); for (int i = 0; i < N; i++) MessageBoard(i, (X / (1LL << col[i])) % 2); }
#include "Ioi.h" #include <vector> #include <queue> #include <algorithm> using namespace std; vector<int>I[10009]; int dist[10009], par[10009], cols[10009], vv[20009], cntv; int N, M; bool used[60]; void make_ransuu2(int B) { for (int i = 0; i < B; i++) vv[i] = i; unsigned long long x = 1640; for (int i = 0; i < 1000000; i++) { x ^= x << 13; x ^= x >> 7; x ^= x << 17; int u1 = (x % B); x ^= x << 13; x ^= x >> 7; x ^= x << 17; int u2 = (x % B); swap(vv[u1], vv[u2]); } } void dfs2(int pos) { if (cols[pos] >= 0) return; cols[pos] = cntv % 60; cntv++; for (int i = 0; i < I[pos].size(); i++) dfs2(I[pos][i]); } vector<int> nearest(int sta, int rem) { for (int i = 0; i < N; i++) dist[i] = (1 << 30); queue<int>Q; Q.push(sta); dist[sta] = 0; while (!Q.empty()) { int pos = Q.front(); Q.pop(); for (int i = 0; i < I[pos].size(); i++) { int to = I[pos][i]; if (dist[to] > dist[pos] + 1) { dist[to] = dist[pos] + 1; par[to] = pos; Q.push(to); } } } int id = 0, minx = 10000; for (int i = 0; i < N; i++) { if (cols[i] == rem && dist[i] < minx) { minx = dist[i]; id = i; } } vector<int>U; while (true) { U.push_back(id); if (id == sta) break; id = par[id]; } reverse(U.begin(), U.end()); return U; } long long Ioi(int NN, int MM, int A[], int B[], int P, int V, int T) { N = NN; M = MM; make_ransuu2(M); for (int i = 0; i < M; i++) { I[A[vv[i]]].push_back(B[vv[i]]); I[B[vv[i]]].push_back(A[vv[i]]); } for (int i = 0; i < N; i++) cols[i] = -1; dfs2(0); int cx = P; long long rem = 0; for (int i = 0; i < 60; i++) { vector<int>E; int id = -1; for (int j = 0; j < 60; j++) { if (used[j] == true) continue; vector<int>F = nearest(cx, j); if (E.size() == 0 || E.size() > F.size()) { E = F; id = j; } } int F = V; for (int j = 1; j < E.size(); j++) { F = Move(E[j]); } rem += 1LL * F * (1LL << id); if (E.size() >= 1) cx = E[E.size() - 1]; used[id] = true; } return rem; }

Compilation message (stderr)

Joi.cpp: In function 'void dfs(int)':
Joi.cpp:28:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < G[pos].size(); i++) dfs(G[pos][i]);
                  ~~^~~~~~~~~~~~~~~

Ioi.cpp: In function 'void dfs2(int)':
Ioi.cpp:31:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < I[pos].size(); i++) dfs2(I[pos][i]);
                  ~~^~~~~~~~~~~~~~~
Ioi.cpp: In function 'std::vector<int> nearest(int, int)':
Ioi.cpp:40:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = 0; i < I[pos].size(); i++) {
                   ~~^~~~~~~~~~~~~~~
Ioi.cpp: In function 'long long int Ioi(int, int, int*, int*, int, int, int)':
Ioi.cpp:81:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int j = 1; j < E.size(); j++) {
                   ~~^~~~~~~~~~
#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...