Submission #573556

#TimeUsernameProblemLanguageResultExecution timeMemory
573556MadokaMagicaFanAirline Route Map (JOI18_airline)C++14
100 / 100
725 ms25412 KiB
#include "bits/stdc++.h" using namespace std; using ll = long long; const ll inf = 1e9; const int md1 = 1e9+7; const int md2 = 998244353; #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() #define sz(v) ((int)v.size()) #define forn(i,n) for(int i = 0; i < n; ++i) #define forbe(i,b,e) for(int i = b; i < e; ++i) #define pb push_back #define pry puts("YES") #define prn puts("NO") #define endl '\n' #define fst first #define scn second const int N = 1e3; vector<int> adj[N+12]; void InitG(int v, int u); void MakeG(int pos, int c, int d); void addadj(int a, int b) { adj[a].pb(b); adj[b].pb(a); return; } void Alice(int n, int m, int a[], int b[]) { for (int i = 0; i < m; ++i) addadj(a[i],b[i]); for (int i = 0; i < 9; ++i) addadj(n+i,n+i+1); for (int i = 0; i < 10; ++i) addadj(n+10,n+i); for (int i = 0; i < n+10; ++i) addadj(n+11,i); for (int i = 0; i < n; ++i) for (int j = 0; j < 10; ++j) if (i&(1<<j)) addadj(i, n+j); int u = 0; for (int i = 0; i < n+13; ++i) u += sz(adj[i]); u >>= 1; InitG(n+12,u); u = 0; for (int i = 0; i < n+13; ++i) { for (int x : adj[i]) { if (x > i) continue; assert(x!=i); MakeG(u,i,x); ++u; } } }
#include "bits/stdc++.h" using namespace std; using ll = long long; const ll inf = 1e9; const int md1 = 1e9+7; const int md2 = 998244353; #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() #define sz(v) ((int)v.size()) #define forn(i,n) for(int i = 0; i < n; ++i) #define forbe(i,b,e) for(int i = b; i < e; ++i) #define pb push_back #define pry puts("YES") #define prn puts("NO") #define endl '\n' #define fst first #define scn second const int N = 1e3; vector<int> adj[N+12]; void addadj(int a, int b) { adj[a].pb(b); adj[b].pb(a); return; } void InitMap(int n, int m); void MakeMap(int a, int b); void Bob(int v, int u, int c[], int d[]) { int n = v-12; if (n==1) { InitMap(1,0); return; } for (int i = 0; i < v; ++i) adj[i].clear(); for (int i = 0; i < u; ++i) { addadj(c[i],d[i]); } int endnode = -1; int beginnode = -1; bitset<N+12> special; for (int i = 0; i < v; ++i) special[i] = 1; for (int i = 0; i < v; ++i) { if (sz(adj[i]) == v-2) endnode = i; } special[endnode] = 0; for (int x : adj[endnode]) special[x] = 0; for (int i = 0; i < v; ++i) if(special[i]) beginnode = i; special[beginnode] = 0; for (int x : adj[beginnode]) special[x] = 1; vector<int> realval(v,0); vector<int> sval; for (int i = 0; i < v; ++i) { if (!special[i]) continue; int deg = 0; for (int x : adj[i]) { if (!special[x]) continue; ++deg; } if (deg==1) sval.pb(i); } int start = 0; assert(sz(sval)==2); if (sz(adj[sval[0]]) > sz(adj[sval[1]])) start = sval[1]; else start = sval[0]; int z = 9; while (1) { int nxt = -1; special[start]=0; for (int x : adj[start]) { if (special[x]) nxt=x; realval[x] += (1<<z); } if (nxt==-1) break; --z; start = nxt; } for (int x : adj[beginnode]) special[x] = 1; special[endnode] = 1; special[beginnode] = 1; int m = 0; for (int i = 0; i < v; ++i) { if (special[i]) continue; for (int x : adj[i]) { if (!special[x]) ++m; } } InitMap(n,m>>1); for (int i = 0; i < v; ++i) { if (special[i]) continue; for (int x : adj[i]) { if (special[x]) continue; if (x > i) continue; MakeMap(realval[i], realval[x]); } } return; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...