Submission #1012123

# Submission time Handle Problem Language Result Execution time Memory
1012123 2024-07-01T16:38:11 Z amirhoseinfar1385 Parachute rings (IOI12_rings) C++17
52 / 100
824 ms 262144 KB
#include<bits/stdc++.h>
//#include "rings.h"
//#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC target("avx2")
using namespace std;
const int maxn=1000000+10;
vector<int>cand;
int n;
struct gr{
	pair<int,int>mx;
	int par[maxn],sz[maxn],dordare,m,c,moalefedordar;
	vector<int>adjs[maxn];
	gr(){
		for(int i=0;i<maxn;i++){
			par[i]=i;
			sz[i]=1;
		}
		mx=make_pair(0,-1);
		m=0;
		dordare=moalefedordar=c=m=0;
	}
	void con(int u,int v){
		m++;
		//adjs[v].push_back(u);
		if(adjs[u].size()<=3){
			adjs[u].push_back(v);
		}
		if(adjs[v].size()<=3){
			adjs[v].push_back(u);
		}
		mx=max(mx,make_pair((int)adjs[u].size(),u));
		mx=max(mx,make_pair((int)adjs[v].size(),v));
		if(par[u]==v){
			dordare++;
			moalefedordar=sz[u];
		}else{
			c--;
			int pu=par[u],pv=par[v],x=sz[u]+sz[v];
			sz[pu]=x;
			sz[pv]=x;
			par[pu]=pv;
			par[pv]=pu;
		}
	}
}gr[5];

void Init(int N){
	//int n=N;
	n=N;
	for(int i=0;i<5;i++){
		gr[i].c=n;
	}
}
vector<pair<int,int>>getalle(){
	vector<pair<int,int>>ret;
	for(int i=0;i<n;i++){
		for(auto x:gr[0].adjs[i]){
			if(x>i){
				ret.push_back(make_pair(i,x));
			}
		}
	}
	return ret;
}

void Link(int A, int B){
	int u=A;
	int v=B;
	int f=(((gr[0].mx).first>=3));
	if(gr[0].mx.first<3){
		gr[0].con(u,v);
	}
	if((int)cand.size()>0){
		for(int i=1;i<=4;i++){
			if(gr[i].dordare==1||gr[i].mx.first>=3||u==cand[i-1]||v==cand[i-1]){
				continue;
			}
			gr[i].con(u,v);
		}
	}
	if(f==0&&(gr[0].mx).first>=3){
		int z=(gr[0].mx).second;
		for(auto x:gr[0].adjs[z]){
			cand.push_back(x);
		}
		cand.push_back(z);
		vector<pair<int,int>>v=getalle();
		for(int i=0;i<(int)cand.size();i++){
			for(auto x:v){
				if(gr[i+1].dordare==1||gr[i+1].mx.first>=3||x.first==cand[i]||x.second==cand[i]){
					continue;
				}
				gr[i+1].con(x.first,x.second);
			}
		}
	}
}

int CountCritical(){
	if((gr[0].mx).first>=3){
		int res=0;
		for(int i=1;i<=4;i++){
			if(gr[i].dordare==0&&(gr[i].mx).first<3){
				res++;
			}
		}
		return res;
	}
	if(gr[0].dordare==0){
		return n;
	}
	if(gr[0].dordare>=2){
		return 0;
	}
	return gr[0].moalefedordar;
}
# Verdict Execution time Memory Grader output
1 Correct 63 ms 156772 KB Output is correct
2 Correct 64 ms 157520 KB Output is correct
3 Correct 63 ms 157100 KB Output is correct
4 Correct 59 ms 157008 KB Output is correct
5 Correct 76 ms 157012 KB Output is correct
6 Correct 61 ms 157012 KB Output is correct
7 Correct 58 ms 157008 KB Output is correct
8 Correct 62 ms 157128 KB Output is correct
9 Correct 62 ms 157524 KB Output is correct
10 Correct 65 ms 157548 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 205 ms 173136 KB Output is correct
2 Correct 824 ms 241108 KB Output is correct
3 Correct 190 ms 159056 KB Output is correct
4 Correct 607 ms 187988 KB Output is correct
5 Correct 538 ms 188076 KB Output is correct
6 Correct 548 ms 187096 KB Output is correct
7 Correct 196 ms 159824 KB Output is correct
8 Runtime error 682 ms 262144 KB Execution killed with signal 9
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 63 ms 156772 KB Output is correct
2 Correct 64 ms 157520 KB Output is correct
3 Correct 63 ms 157100 KB Output is correct
4 Correct 59 ms 157008 KB Output is correct
5 Correct 76 ms 157012 KB Output is correct
6 Correct 61 ms 157012 KB Output is correct
7 Correct 58 ms 157008 KB Output is correct
8 Correct 62 ms 157128 KB Output is correct
9 Correct 62 ms 157524 KB Output is correct
10 Correct 65 ms 157548 KB Output is correct
11 Correct 68 ms 157528 KB Output is correct
12 Correct 70 ms 158548 KB Output is correct
13 Correct 69 ms 158068 KB Output is correct
14 Correct 66 ms 157012 KB Output is correct
15 Correct 64 ms 157000 KB Output is correct
16 Correct 66 ms 157264 KB Output is correct
17 Correct 66 ms 157012 KB Output is correct
18 Correct 66 ms 157012 KB Output is correct
19 Correct 64 ms 157268 KB Output is correct
20 Correct 64 ms 158288 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 63 ms 156772 KB Output is correct
2 Correct 64 ms 157520 KB Output is correct
3 Correct 63 ms 157100 KB Output is correct
4 Correct 59 ms 157008 KB Output is correct
5 Correct 76 ms 157012 KB Output is correct
6 Correct 61 ms 157012 KB Output is correct
7 Correct 58 ms 157008 KB Output is correct
8 Correct 62 ms 157128 KB Output is correct
9 Correct 62 ms 157524 KB Output is correct
10 Correct 65 ms 157548 KB Output is correct
11 Correct 68 ms 157528 KB Output is correct
12 Correct 70 ms 158548 KB Output is correct
13 Correct 69 ms 158068 KB Output is correct
14 Correct 66 ms 157012 KB Output is correct
15 Correct 64 ms 157000 KB Output is correct
16 Correct 66 ms 157264 KB Output is correct
17 Correct 66 ms 157012 KB Output is correct
18 Correct 66 ms 157012 KB Output is correct
19 Correct 64 ms 157268 KB Output is correct
20 Correct 64 ms 158288 KB Output is correct
21 Correct 69 ms 158036 KB Output is correct
22 Correct 72 ms 158548 KB Output is correct
23 Correct 74 ms 158964 KB Output is correct
24 Correct 74 ms 158420 KB Output is correct
25 Correct 62 ms 157520 KB Output is correct
26 Correct 77 ms 159060 KB Output is correct
27 Correct 84 ms 159572 KB Output is correct
28 Correct 74 ms 157264 KB Output is correct
29 Correct 72 ms 157896 KB Output is correct
30 Correct 94 ms 160084 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 63 ms 156772 KB Output is correct
2 Correct 64 ms 157520 KB Output is correct
3 Correct 63 ms 157100 KB Output is correct
4 Correct 59 ms 157008 KB Output is correct
5 Correct 76 ms 157012 KB Output is correct
6 Correct 61 ms 157012 KB Output is correct
7 Correct 58 ms 157008 KB Output is correct
8 Correct 62 ms 157128 KB Output is correct
9 Correct 62 ms 157524 KB Output is correct
10 Correct 65 ms 157548 KB Output is correct
11 Correct 205 ms 173136 KB Output is correct
12 Correct 824 ms 241108 KB Output is correct
13 Correct 190 ms 159056 KB Output is correct
14 Correct 607 ms 187988 KB Output is correct
15 Correct 538 ms 188076 KB Output is correct
16 Correct 548 ms 187096 KB Output is correct
17 Correct 196 ms 159824 KB Output is correct
18 Runtime error 682 ms 262144 KB Execution killed with signal 9
19 Halted 0 ms 0 KB -