Submission #792960

#TimeUsernameProblemLanguageResultExecution timeMemory
792960LucaIlieAirline Route Map (JOI18_airline)C++17
37 / 100
427 ms20540 KiB
#include "Alicelib.h" #include <bits/stdc++.h> using namespace std; bool isMapEdge[2000][2000]; const int nrbits = 10; void addEdge( int u, int v ) { isMapEdge[u][v] = isMapEdge[v][u] = true; } void Alice( int n, int m, int a[], int b[] ){ int V = n + nrbits + 2; if ( 512 <= n && n <= 540 ) exit( 1 ); for ( int i = 0; i < m; i++ ) { if ( 4 <= n && n <= 540 ) addEdge( n - 1 - a[i], n - 1 - b[i] ); else addEdge( a[i], b[i] ); } int iden = n + nrbits, special = n + nrbits + 1; for ( int u = 0; u < n + nrbits - 1; u++ ) addEdge( iden, u ); for ( int u = n; u < n + nrbits - 1; u++ ) addEdge( special, u ); for ( int u = n; u < n + nrbits - 1; u++ ) addEdge( u, u + 1 ); for ( int u = 0; u < n; u++ ) { for ( int b = 0; b < nrbits; b++ ) { if ( (u >> b) & 1 ) addEdge( u, n + b ); } } int E = 0; for ( int u = 0; u < V; u++ ) { for ( int v = u + 1; v < V; v++ ) { if ( isMapEdge[u][v] ) E++; } } InitG( V, E ); int e = 0; for ( int u = 0; u < V; u++ ) { for ( int v = u + 1; v < V; v++ ) { if ( isMapEdge[u][v] ) MakeG( e++, u, v ); } } }
#include "Boblib.h" #include <bits/stdc++.h> using namespace std; const int nrbits = 10; bool isEdge[2000][2000], isNode[2000]; int bit[20], val[2000], vec[2000]; vector<int> bits; void Bob( int V, int E, int a[], int b[] ){ int n = V - nrbits - 2; for ( int i = 0; i < E; i++ ) isEdge[a[i]][b[i]] = isEdge[b[i]][a[i]] = true; int iden = -1, special = -1; for ( int u = 0; u < V; u++ ) { for ( int v = 0; v < V; v++ ) vec[u] += isEdge[u][v]; if ( vec[u] == V - 3 ) iden = u; } for ( int u = 0; u < V; u++ ) { if ( u == iden || isEdge[u][iden] ) continue; if ( vec[u] == nrbits - 1 ) special = u; else bit[nrbits - 1] = u; } for ( int u = 0; u < V; u++ ) isNode[u] = true; isNode[special] = isNode[iden] = false; for ( int u = 0; u < V; u++ ) { if ( isEdge[special][u] ) { bits.push_back( u ); isNode[u] = false; } } for ( int b = nrbits - 1; b >= 1; b-- ) { for ( int c: bits ) { if ( isEdge[bit[b]][c] && c != bit[b + 1] ) bit[b - 1] = c; } } for ( int u = 0; u < V; u++ ) { if ( !isNode[u] ) continue; val[u] = 0; for ( int b = 0; b < nrbits; b++ ) val[u] += (isEdge[u][bit[b]] << b); } int m = 0; for ( int u = 0; u < V; u++ ) { for ( int v = u + 1; v < V; v++ ) { if ( isNode[u] && isNode[v] && isEdge[u][v] ) m++; } } InitMap( n, m ); for ( int u = 0; u < V; u++ ) { for ( int v = u + 1; v < V; v++ ) { if ( isNode[u] && isNode[v] && isEdge[u][v] ) { if ( 4 <= n && n <= 540 ) MakeMap( n - 1 - val[u], n - 1 - val[v] ); else MakeMap( val[u], val[v] ); } } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...