답안 #1012122

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1012122 2024-07-01T16:37:32 Z amirhoseinfar1385 낙하산 고리들 (IOI12_rings) C++17
52 / 100
809 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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 62 ms 156832 KB Output is correct
2 Correct 62 ms 157576 KB Output is correct
3 Correct 60 ms 157268 KB Output is correct
4 Correct 58 ms 156956 KB Output is correct
5 Correct 58 ms 157008 KB Output is correct
6 Correct 62 ms 157008 KB Output is correct
7 Correct 62 ms 157008 KB Output is correct
8 Correct 61 ms 156916 KB Output is correct
9 Correct 64 ms 157524 KB Output is correct
10 Correct 67 ms 157524 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 239 ms 173140 KB Output is correct
2 Correct 809 ms 241284 KB Output is correct
3 Correct 207 ms 159164 KB Output is correct
4 Correct 579 ms 187988 KB Output is correct
5 Correct 607 ms 188244 KB Output is correct
6 Correct 567 ms 187148 KB Output is correct
7 Correct 203 ms 159828 KB Output is correct
8 Runtime error 672 ms 262144 KB Execution killed with signal 9
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 62 ms 156832 KB Output is correct
2 Correct 62 ms 157576 KB Output is correct
3 Correct 60 ms 157268 KB Output is correct
4 Correct 58 ms 156956 KB Output is correct
5 Correct 58 ms 157008 KB Output is correct
6 Correct 62 ms 157008 KB Output is correct
7 Correct 62 ms 157008 KB Output is correct
8 Correct 61 ms 156916 KB Output is correct
9 Correct 64 ms 157524 KB Output is correct
10 Correct 67 ms 157524 KB Output is correct
11 Correct 64 ms 157520 KB Output is correct
12 Correct 72 ms 158548 KB Output is correct
13 Correct 67 ms 158128 KB Output is correct
14 Correct 65 ms 157164 KB Output is correct
15 Correct 62 ms 157012 KB Output is correct
16 Correct 62 ms 157268 KB Output is correct
17 Correct 63 ms 157008 KB Output is correct
18 Correct 63 ms 157008 KB Output is correct
19 Correct 63 ms 157264 KB Output is correct
20 Correct 67 ms 158392 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 62 ms 156832 KB Output is correct
2 Correct 62 ms 157576 KB Output is correct
3 Correct 60 ms 157268 KB Output is correct
4 Correct 58 ms 156956 KB Output is correct
5 Correct 58 ms 157008 KB Output is correct
6 Correct 62 ms 157008 KB Output is correct
7 Correct 62 ms 157008 KB Output is correct
8 Correct 61 ms 156916 KB Output is correct
9 Correct 64 ms 157524 KB Output is correct
10 Correct 67 ms 157524 KB Output is correct
11 Correct 64 ms 157520 KB Output is correct
12 Correct 72 ms 158548 KB Output is correct
13 Correct 67 ms 158128 KB Output is correct
14 Correct 65 ms 157164 KB Output is correct
15 Correct 62 ms 157012 KB Output is correct
16 Correct 62 ms 157268 KB Output is correct
17 Correct 63 ms 157008 KB Output is correct
18 Correct 63 ms 157008 KB Output is correct
19 Correct 63 ms 157264 KB Output is correct
20 Correct 67 ms 158392 KB Output is correct
21 Correct 74 ms 157880 KB Output is correct
22 Correct 93 ms 158544 KB Output is correct
23 Correct 81 ms 159060 KB Output is correct
24 Correct 81 ms 158544 KB Output is correct
25 Correct 64 ms 157296 KB Output is correct
26 Correct 80 ms 159312 KB Output is correct
27 Correct 79 ms 159704 KB Output is correct
28 Correct 74 ms 157392 KB Output is correct
29 Correct 74 ms 157780 KB Output is correct
30 Correct 90 ms 159896 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 62 ms 156832 KB Output is correct
2 Correct 62 ms 157576 KB Output is correct
3 Correct 60 ms 157268 KB Output is correct
4 Correct 58 ms 156956 KB Output is correct
5 Correct 58 ms 157008 KB Output is correct
6 Correct 62 ms 157008 KB Output is correct
7 Correct 62 ms 157008 KB Output is correct
8 Correct 61 ms 156916 KB Output is correct
9 Correct 64 ms 157524 KB Output is correct
10 Correct 67 ms 157524 KB Output is correct
11 Correct 239 ms 173140 KB Output is correct
12 Correct 809 ms 241284 KB Output is correct
13 Correct 207 ms 159164 KB Output is correct
14 Correct 579 ms 187988 KB Output is correct
15 Correct 607 ms 188244 KB Output is correct
16 Correct 567 ms 187148 KB Output is correct
17 Correct 203 ms 159828 KB Output is correct
18 Runtime error 672 ms 262144 KB Execution killed with signal 9
19 Halted 0 ms 0 KB -