Submission #420431

#TimeUsernameProblemLanguageResultExecution timeMemory
420431kostia244Airline Route Map (JOI18_airline)C++17
0 / 100
651 ms25004 KiB
#include "Alicelib.h" #include<bits/stdc++.h> using namespace std; void Alice(int n, int m, int A[], int B[] ){ if(n < 3 || m == 0) { InitG(n, m); for(int i = 0; i < m; i++) MakeG(i, A[i], B[i]); return; } vector<int> label(3024); for(int z = 0, i = 0; i < 1000; i++) { while(z > 1 && !(z&(z-1))) z++; label[i] = z ? z : 1023; z++; if(i < 5) { //cout << i << " = " << label[i] << endl; } } vector<array<int, 2>> edges; vector<int> baka(n); for(int i = 0; i < m; i++) { baka[A[i]]++; baka[B[i]]++; } for(int i = 0; i < m; i++) edges.push_back({A[i], B[i]}); for(int i = 0; i < n; i++) if(baka[i]) edges.push_back({n, i}); edges.push_back({n+1, n}); for(int bit = 0; bit < 10; bit++) { if(bit) edges.push_back({n+1+bit, n+2+bit}); for(int i = 0; i < n; i++) if((label[i]>>bit)&1) { edges.push_back({n+2+bit, i}); } } //for(auto [u, v] : edges) cout << u << " " << v << endl; InitG(n+12, edges.size()); for(int i = 0; i < edges.size(); i++) MakeG(i, edges[i][0], edges[i][1]); }
#include "Boblib.h" #include<bits/stdc++.h> using namespace std; void Bob( int V, int U, int C[], int D[] ){ if(V < 3 || U == 0) { InitMap(V, U); for(int i = 0; i < U; i++) MakeMap(C[i], D[i]); return; } vector<int> label(3024); for(int z = 0, i = 0; i < 1000; i++) { while(z > 1 && !(z&(z-1))) z++; label[z ? z : 1023] = i; z++; } vector<vector<int>> g(V); vector<int> real(V, -1); for(int i = 0; i < U; i++) { g[C[i]].push_back(D[i]); g[D[i]].push_back(C[i]); } int sun = 0; while(g[sun].size()!=1) sun++; sun = g[sun][0]; for(auto i : g[sun]) if(g[i].size()>1)real[i] = 0; int start = -1, prev = -1; for(int i = 0; i < V; i++) if(!real[i]) { int popcnt = -1; for(int j : g[i]) if(real[j] && j != sun) { //cout << i << " to " << j<< endl; if(popcnt == -1) popcnt = j; if(popcnt != j) popcnt = -2; } if(popcnt >= 0) { //cout << "uwu " << i << " " << popcnt << endl; start = popcnt; break; } } //cout << start << "hm\n" << endl; vector<int> bits {start}; while(bits.size() < 10) { for(auto i : g[start]) if(real[i] && i != prev) { prev = start; start = i; break; } bits.push_back(start); } for(int i = 0; i < 10; i++) { for(int j : g[bits[i]]) if(real[j] != -1) real[j] += 1<<i; } //for(auto i : real) cout << i << " "; cout << endl; for(int &i : real) if(i != -1) i = label[i]; //for(auto i : real) cout << i << " "; cout << endl; int ed = 0; for(int i = 0; i < U; i++) ed += real[C[i]] >= 0 && real[D[i]] >= 0; InitMap( g[sun].size()-1, ed ); for(int i = 0; i < U; i++) { if(real[C[i]] >= 0 && real[D[i]] >= 0) MakeMap(real[C[i]], real[D[i]]); } }

Compilation message (stderr)

Alice.cpp: In function 'void Alice(int, int, int*, int*)':
Alice.cpp:41:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::array<int, 2> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |  for(int i = 0; i < edges.size(); i++)
      |                 ~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...