Submission #313422

# Submission time Handle Problem Language Result Execution time Memory
313422 2020-10-16T00:24:19 Z arthur_nascimento Airline Route Map (JOI18_airline) C++14
0 / 100
2500 ms 81328 KB
#include "Alicelib.h"
 
#include <cassert>
 
#include <cstdio>
 
#include <bits/stdc++.h>
 
#define maxn 110
 
#define maxK 4100
 
#define ll long long
 
#define pb push_back
 
#define pii pair<int,int>
 
#define mod 1000000007 
 
#define debug(args...) //fprintf(stderr,args)
 
using namespace std;
 
 
void Alice( int N, int M, int A[], int B[] ){
 
 
	vector<pii> v;
 
	for(int i=0;i<M;i++)
		v.pb({A[i],B[i]});
 
	for(int i=0;i<10;i++)
		for(int j=0;j<N;j++)
			if(j & (1<<i))
				v.pb({i+N,j});
 
	for(int i=0;i<N+10;i++){
		if(i < N){
			v.pb({10+N,i});
			v.pb({11+N,i});
		}
		else if (i == N);
		else if(i < N + 5)
			v.pb({10+N,i});
		else
			v.pb({11+N,i});
	}
 
	for(int i=0;i<9;i++)
		v.pb({i+N,i+N+1});
 
 
	InitG(N+12,v.size());
 
	int bla = 0;
	
	for(pii i : v)
		MakeG(bla++, i.first,i.second);
	
 
}
#include "Boblib.h"
 
#include <cassert>
 
#include <cstdio>
 
#define maxn 1111
 
#include <bits/stdc++.h>
 
 
 
#define maxK 4100
 
#define ll long long
 
#define pb push_back
 
#define pii pair<int,int>
 
#define mod 1000000007 
 
#define debug(args...) fprintf(stderr,args)
 
using namespace std;
 
int mrk[maxn];
 
int dg[maxn];
 
vector<int> L[maxn];
 
int real_id[maxn];

int vis[maxn];
 
void go(int vx,int num,int p=-1){
	//if(vis[vx]) return;
	vis[vx] = 1;
	for(int i : L[vx])
		real_id[i] += num;
	debug("go %d with %d\n",vx,num);
	for(int i : L[vx])
		if(mrk[i] == 1 && i != p)
			go(i,2*num,vx);
}
 
 
void Bob( int V, int U, int C[], int D[] ){
 
	for(int i=0;i<V;i++) L[i].clear(), mrk[i] = dg[i] = vis[i] = 0;
 
	for(int i=0;i<U;i++){
		dg[C[i]]++, dg[D[i]]++;
		L[C[i]].pb(D[i]);
		L[D[i]].pb(C[i]);
	}
 
	vector<int> id;
	for(int i=0;i<V;i++)
		id.pb(i);
	sort(id.begin(), id.end(), [](int i,int j){
		return dg[i] > dg[j];
	});
 
	debug("id %d (%d), %d(%d)\n",id[0],dg[id[0]],id[1],dg[id[1]]);
 
	for(int i : L[id[0]])
		mrk[i]++;
	for(int i : L[id[1]])
		mrk[i]++;

	int n = V - 12;
	assert(dg[id[0]] == n + 5 && dg[id[1]] == n + 4);
 
	int ini = -1;
	for(int i=0;i<V;i++) if(mrk[i] == 0 && i != id[0] && i != id[1]){
		//assert(ini == -1);
		ini = i;
	}

	//assert(ini >= 0);
 
	go(ini,1);
 
	for(int i=0;i<V;i++)
		debug("mrk[%d] = %d, real_id = %d\n",i,mrk[i],real_id[i]);
 
	vector<pii> ans	;
	for(int i=0;i<U;i++)
		if(mrk[C[i]] == 2 && mrk[D[i]] == 2){
			debug("add %d %d -> %d %d\n",C[i],D[i],real_id[C[i]], real_id[D[i]]);
			ans.pb({real_id[C[i]], real_id[D[i]]});
		}
 
	InitMap( V - 12, ans.size() );
 
	for(pii i : ans)
 
		MakeMap( i.first, i.second );
 
}
 
# Verdict Execution time Memory Grader output
1 Correct 7 ms 6912 KB Output is correct
2 Correct 7 ms 6912 KB Output is correct
3 Correct 8 ms 6912 KB Output is correct
4 Correct 6 ms 6656 KB Output is correct
5 Correct 7 ms 6912 KB Output is correct
6 Correct 7 ms 6912 KB Output is correct
7 Execution timed out 3050 ms 81328 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 6912 KB Output is correct
2 Correct 7 ms 6912 KB Output is correct
3 Correct 8 ms 6912 KB Output is correct
4 Correct 6 ms 6656 KB Output is correct
5 Correct 7 ms 6912 KB Output is correct
6 Correct 7 ms 6912 KB Output is correct
7 Execution timed out 3050 ms 81328 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 723 ms 34908 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -