Submission #680080

#TimeUsernameProblemLanguageResultExecution timeMemory
680080rainboyAirline Route Map (JOI18_airline)C++17
100 / 100
754 ms20728 KiB
#include "Alicelib.h" void Alice(int n, int m, int *ii, int *jj) { const int N = 1000, L = 10; if (n == 1) { InitG(1, 0); return; } if (n == 2) { InitG(2, m); if (m == 1) MakeG(0, 0, 1); return; } int bb[N]; for (int b = 0, i = 0; i + 1 < n; b++) if ((b & b - 1) != 0) bb[i++] = b; bb[n - 1] = (1 << L) - 1; int n_ = n + L + 2, m_ = m + L + 1 + n; for (int i = 0; i < n; i++) for (int l = 0; l < L; l++) if ((bb[i] & 1 << l) != 0) m_++; InitG(n_, m_); m_ = 0; for (int h = 0; h < m; h++) MakeG(m_++, ii[h], jj[h]); for (int l = 0; l + 1 < L; l++) MakeG(m_++, n + l, n + l + 1); MakeG(m_++, n + L - 1, n + L + 1); MakeG(m_++, n + L, n + L + 1); for (int i = 0; i < n; i++) MakeG(m_++, n + L, i); for (int i = 0; i < n; i++) for (int l = 0; l < L; l++) if ((bb[i] & 1 << l) != 0) MakeG(m_++, n + l, i); }
#include "Boblib.h" #include <cstdlib> #include <cstring> void Bob(int n_, int m_, int ii[], int jj[]) { const int N_ = 1012, L = 10; int *ej[N_], eo[N_], bb[N_], pp[1 << L]; char type[N_]; if (n_ == 1) { InitMap(1, 0); return; } if (n_ == 2) { InitMap(2, m_); if (m_ == 1) MakeMap(0, 1); return; } memset(eo, 0, n_ * sizeof *eo); int n = n_ - L - 2; for (int h = 0; h < m_; h++) { int i = ii[h], j = jj[h]; eo[i]++, eo[j]++; } for (int i = 0; i < n_; i++) ej[i] = (int *) malloc((eo[i] + 1) * sizeof *ej[i]), eo[i] = 0; for (int h = 0; h < m_; h++) { int i = ii[h], j = jj[h]; ej[i][eo[i]++] = j, ej[j][eo[j]++] = i; } memset(type, 0, n_ * sizeof *type); int u; for (u = 0; u < n_; u++) if (eo[u] == 2) { int v = ej[u][0], w = ej[u][1], tmp; if (eo[v] < eo[w]) tmp = v, v = w, w = tmp; for (int o = eo[v]; o--; ) { int x = ej[v][o]; if (x != u) type[x] = 1; } type[u] = -1; u = w; break; } for (int l = L - 1; l >= 0; l--) { int w = -1; for (int o = eo[u]; o--; ) { int v = ej[u][o]; if (type[v] == 1) bb[v] |= 1 << l; else if (type[v] == 0) w = v; } type[u] = -1; u = w; } for (int b = 0, i = 0; i + 1 < n; b++) if ((b & b - 1) != 0) pp[b] = i++; pp[(1 << L) - 1] = n - 1; int m = 0; for (int h = 0; h < m_; h++) { int i = ii[h], j = jj[h]; if (type[i] == 1 && type[j] == 1) m++; } InitMap(n, m); for (int h = 0; h < m_; h++) { int i = ii[h], j = jj[h]; if (type[i] == 1 && type[j] == 1) MakeMap(pp[bb[i]], pp[bb[j]]); } }

Compilation message (stderr)

Alice.cpp: In function 'void Alice(int, int, int*, int*)':
Alice.cpp:17:14: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
   17 |   if ((b & b - 1) != 0)
      |            ~~^~~

Bob.cpp: In function 'void Bob(int, int, int*, int*)':
Bob.cpp:59:14: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
   59 |   if ((b & b - 1) != 0)
      |            ~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...