Submission #954850

#TimeUsernameProblemLanguageResultExecution timeMemory
954850SkywkAirline Route Map (JOI18_airline)C++17
0 / 100
542 ms40984 KiB
#include "Alicelib.h" #include <cassert> #include <cstdio> #include <bits/stdc++.h> using namespace std; vector<array<int, 2>> edgesA; void Alice(int N, int M, int A[], int B[]){ int supremeNode = N; int startNode = N + 11; int bitNode[10]; iota(bitNode, bitNode + 10, N + 1); int V = N + 12; for(int i=0; i<M; i++){ edgesA.push_back({A[i], B[i]}); } for(int i=0; i<N; i++){ edgesA.push_back({supremeNode, i}); } edgesA.push_back({startNode, supremeNode}); for(int x=1; x<10; x++){ edgesA.push_back({bitNode[x], bitNode[x-1]}); } for(int i=0; i<N; i++){ for(int x=0; x<10; x++){ if(i & (1 << x)){ edgesA.push_back({i, bitNode[x]}); } } } int U = edgesA.size(); InitG(V, U); for(int i=0; i<U; i++){ MakeG(i, edgesA[i][0], edgesA[i][1]); } }
#include "Boblib.h" #include <cassert> #include <cstdio> #include <bits/stdc++.h> using namespace std; const int MAXN = 1000; vector<int> adj[MAXN + 12]; int degree[MAXN + 12]; int vis[MAXN + 12]; int value[MAXN + 12]; vector<array<int, 2>> edgesB; void Bob(int V, int U, int C[], int D[]){ memset(degree, 0, sizeof(degree[0]) * V); int N = V - 12; for(int i=0; i<U; i++){ degree[C[i]]++; degree[D[i]]++; adj[C[i]].push_back(D[i]); adj[D[i]].push_back(C[i]); } int startNode = -1; int supremeNode = -1; for(int i=0; i<V; i++){ if(degree[i] == 1 && degree[adj[i][0]] == N + 1){ startNode = i; supremeNode = adj[i][0]; break; } } memset(vis, 0, sizeof(vis[0]) * V); for(auto u : adj[supremeNode]) vis[u] = 1; vis[startNode] = 2; vis[supremeNode] = 2; int bitNode[10], bitEdges[10]; memset(bitNode, -1, sizeof(bitNode[0]) * 10); memset(bitEdges, 0, sizeof(bitEdges[0]) * 10); for(int i=0; i<N; i++){ for(int x=0; x<10; x++){ bitEdges[x] += (i >> x) & 1; } } for(int i=0; i<V; i++){ if(!vis[i] && degree[i] == bitEdges[0] + 1){ bitNode[0] = i; vis[i] = 2; } } for(int i=1; i<10; i++){ for(auto u : adj[bitNode[i-1]]){ if(vis[u]) continue; bitNode[i] = u; vis[u] = 2; } } memset(value, 0, sizeof(value[0]) * V); for(int i=0; i<10; i++){ for(auto u : adj[bitNode[i]]){ if(vis[u] == 1){ value[u] += (1 << i); } } } for(int i=0; i<U; i++){ if(vis[C[i]] == 1 && vis[D[i]] == 1){ edgesB.push_back({value[C[i]], value[D[i]]}); } } int M = edgesB.size(); InitMap(N, M); for(auto [u, v] : edgesB){ MakeMap(u, v); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...