Submission #350939

# Submission time Handle Problem Language Result Execution time Memory
350939 2021-01-19T10:03:04 Z amunduzbaev Parachute rings (IOI12_rings) C++14
20 / 100
4000 ms 1004 KB
#ifndef EVAL
#include "grader.cpp"
#endif

#include "bits/stdc++.h"
using namespace std;

#define pb push_back
#define ss second
#define ff first

const int N = 5e3+5;
int n;
vector<pair<int, int>> edges[N];
int used[N], vis[N];

void Init(int nn) { n = nn; }

//void merge(int a, int b){
	///* merge two  ds ans cout ans for this new set */
//}

int last;
void Link(int A, int B) {
	//merge(A, B);
	edges[A].pb({B, ++last});
	edges[B].pb({A, last});
}

bool dfs(int u, int p){
	if(vis[u]) return 0;
	int cnt = 0, ok = 1;
	vis[u] = 1;
	for(auto x:edges[u]){
		if(used[x.ss] || x.ff == p) continue;
		if(cnt) return 0;
		cnt++; 
		ok &= dfs(x.ff, u);
	}return ok;
}

int CountCritical(){
	memset(used, 0, sizeof used);
	int cnt = 0;
	for(int i=0;i<n;i++){
		for(auto x:edges[i]) used[x.ss] = 1;
		vis[i] = 1;
		bool ok = 1;
		for(int j=0;j<n && ok;j++){
			if(!vis[j]){
				int cnt = 0;
				for(auto x:edges[j]){
					if(used[x.ss]) continue;
					cnt++;
					ok &= dfs(x.ff, j);
					if(cnt > 2) { ok = 0; break; }
				}
			}
		}
		for(auto x:edges[i]) used[x.ss] = 0;
		memset(vis, 0, sizeof vis);
		cnt += ok;
	}
	return cnt;
}

/*

7 13 
-1
1 2 
-1
0 5 
-1
2 0 
-1
3 2 
-1
3 5 
-1
4 3 
-1


*/
# Verdict Execution time Memory Grader output
1 Correct 1 ms 524 KB Output is correct
2 Correct 121 ms 700 KB Output is correct
3 Correct 45 ms 748 KB Output is correct
4 Correct 10 ms 492 KB Output is correct
5 Correct 194 ms 620 KB Output is correct
6 Correct 737 ms 1004 KB Output is correct
7 Correct 8 ms 492 KB Output is correct
8 Correct 70 ms 620 KB Output is correct
9 Correct 240 ms 748 KB Output is correct
10 Correct 92 ms 748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 748 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 524 KB Output is correct
2 Correct 121 ms 700 KB Output is correct
3 Correct 45 ms 748 KB Output is correct
4 Correct 10 ms 492 KB Output is correct
5 Correct 194 ms 620 KB Output is correct
6 Correct 737 ms 1004 KB Output is correct
7 Correct 8 ms 492 KB Output is correct
8 Correct 70 ms 620 KB Output is correct
9 Correct 240 ms 748 KB Output is correct
10 Correct 92 ms 748 KB Output is correct
11 Execution timed out 4056 ms 844 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 524 KB Output is correct
2 Correct 121 ms 700 KB Output is correct
3 Correct 45 ms 748 KB Output is correct
4 Correct 10 ms 492 KB Output is correct
5 Correct 194 ms 620 KB Output is correct
6 Correct 737 ms 1004 KB Output is correct
7 Correct 8 ms 492 KB Output is correct
8 Correct 70 ms 620 KB Output is correct
9 Correct 240 ms 748 KB Output is correct
10 Correct 92 ms 748 KB Output is correct
11 Execution timed out 4056 ms 844 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 524 KB Output is correct
2 Correct 121 ms 700 KB Output is correct
3 Correct 45 ms 748 KB Output is correct
4 Correct 10 ms 492 KB Output is correct
5 Correct 194 ms 620 KB Output is correct
6 Correct 737 ms 1004 KB Output is correct
7 Correct 8 ms 492 KB Output is correct
8 Correct 70 ms 620 KB Output is correct
9 Correct 240 ms 748 KB Output is correct
10 Correct 92 ms 748 KB Output is correct
11 Runtime error 1 ms 748 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Halted 0 ms 0 KB -