Submission #312673

# Submission time Handle Problem Language Result Execution time Memory
312673 2020-10-14T03:36:51 Z colazcy Checker (COCI19_checker) C++17
110 / 110
622 ms 76508 KB
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
const int maxn = 2e5 + 100;
inline int read(){
	int x = 0;char c = getchar();
	while(!isdigit(c))c = getchar();
	while(isdigit(c))x = x * 10 + c - '0',c = getchar();
	return x;
}
inline int readig(){
	char c = getchar();
	while(!isdigit(c))c = getchar();
	return c - '0';
}
int n,flg;
map<int,int> col[maxn];
inline int bel(int x,int u){
	if(x < u)return 1;
	else return 2;
}
struct edge{
	int u,v,c;
	bool operator < (const edge &rhs)const{
		if(bel(v,u) != bel(rhs.v,u))return bel(v,u) < bel(rhs.v,u);
		return v > rhs.v;
	}
};
vector<edge> G[maxn];
inline void addedge(int u,int v,int d){
	G[u].push_back(edge{u,v,d});
}
inline int chk(int a,int b,int c){
	return !((a == b) || (a == c) || (b == c));
}
int main(){
//	freopen("checker.in","r",stdin);
//	freopen("checker.out","w",stdout);
	read();
	n = read();
	for(int c,i = 1;i < n;i++)c = col[i][i + 1] = col[i + 1][i] = readig(),addedge(i,i + 1,c),addedge(i + 1,i,c);
	col[n][1] = col[1][n] = readig(); addedge(n,1,col[n][1]),addedge(1,n,col[1][n]);
	for(int l,r,c,i = 1;i <= n - 3;i++){
		l = read(),r = read(),c = read();
		addedge(l,r,c);
		addedge(r,l,c);
		col[l][r] = col[r][l] = c;
	}
	for(int i = 1;i <= n;i++)sort(G[i].begin(),G[i].end());
	for(int u = 1;u <= n;u++){
		for(int i = 0;i < (int)G[u].size() - 1;i++){
			int v1 = G[u][i].v,v2 = G[u][i + 1].v;
			if(col[v1].find(v2) == col[v1].end())return puts("neispravna triangulacija"),0;
			if(!chk(G[u][i].c,G[u][i + 1].c,col[v1][v2]))flg = 1;
		}
	}
	if(flg)return puts("neispravno bojenje"),0;
	puts("tocno");
	fclose(stdin);
	fclose(stdout);	
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 10 ms 14464 KB Output is correct
2 Correct 10 ms 14464 KB Output is correct
3 Correct 11 ms 14464 KB Output is correct
4 Correct 10 ms 14464 KB Output is correct
5 Correct 10 ms 14464 KB Output is correct
6 Correct 10 ms 14464 KB Output is correct
7 Correct 10 ms 14464 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 14464 KB Output is correct
2 Correct 10 ms 14464 KB Output is correct
3 Correct 11 ms 14464 KB Output is correct
4 Correct 10 ms 14464 KB Output is correct
5 Correct 10 ms 14464 KB Output is correct
6 Correct 10 ms 14464 KB Output is correct
7 Correct 10 ms 14464 KB Output is correct
8 Correct 12 ms 14976 KB Output is correct
9 Correct 12 ms 14976 KB Output is correct
10 Correct 12 ms 14976 KB Output is correct
11 Correct 12 ms 14976 KB Output is correct
12 Correct 12 ms 14976 KB Output is correct
13 Correct 12 ms 14976 KB Output is correct
14 Correct 12 ms 14976 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 512 ms 74716 KB Output is correct
2 Correct 511 ms 74744 KB Output is correct
3 Correct 447 ms 74680 KB Output is correct
4 Correct 448 ms 74488 KB Output is correct
5 Correct 448 ms 74616 KB Output is correct
6 Correct 608 ms 76504 KB Output is correct
7 Correct 622 ms 76388 KB Output is correct
8 Correct 558 ms 76256 KB Output is correct
9 Correct 556 ms 76396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 495 ms 74744 KB Output is correct
2 Correct 502 ms 74616 KB Output is correct
3 Correct 505 ms 74616 KB Output is correct
4 Correct 502 ms 74652 KB Output is correct
5 Correct 493 ms 74616 KB Output is correct
6 Correct 620 ms 76508 KB Output is correct
7 Correct 620 ms 76508 KB Output is correct
8 Correct 610 ms 76508 KB Output is correct
9 Correct 620 ms 76252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 14464 KB Output is correct
2 Correct 10 ms 14464 KB Output is correct
3 Correct 11 ms 14464 KB Output is correct
4 Correct 10 ms 14464 KB Output is correct
5 Correct 10 ms 14464 KB Output is correct
6 Correct 10 ms 14464 KB Output is correct
7 Correct 10 ms 14464 KB Output is correct
8 Correct 12 ms 14976 KB Output is correct
9 Correct 12 ms 14976 KB Output is correct
10 Correct 12 ms 14976 KB Output is correct
11 Correct 12 ms 14976 KB Output is correct
12 Correct 12 ms 14976 KB Output is correct
13 Correct 12 ms 14976 KB Output is correct
14 Correct 12 ms 14976 KB Output is correct
15 Correct 512 ms 74716 KB Output is correct
16 Correct 511 ms 74744 KB Output is correct
17 Correct 447 ms 74680 KB Output is correct
18 Correct 448 ms 74488 KB Output is correct
19 Correct 448 ms 74616 KB Output is correct
20 Correct 608 ms 76504 KB Output is correct
21 Correct 622 ms 76388 KB Output is correct
22 Correct 558 ms 76256 KB Output is correct
23 Correct 556 ms 76396 KB Output is correct
24 Correct 495 ms 74744 KB Output is correct
25 Correct 502 ms 74616 KB Output is correct
26 Correct 505 ms 74616 KB Output is correct
27 Correct 502 ms 74652 KB Output is correct
28 Correct 493 ms 74616 KB Output is correct
29 Correct 620 ms 76508 KB Output is correct
30 Correct 620 ms 76508 KB Output is correct
31 Correct 610 ms 76508 KB Output is correct
32 Correct 620 ms 76252 KB Output is correct
33 Correct 503 ms 74616 KB Output is correct
34 Correct 498 ms 74616 KB Output is correct
35 Correct 462 ms 74488 KB Output is correct
36 Correct 452 ms 74744 KB Output is correct
37 Correct 501 ms 74616 KB Output is correct
38 Correct 501 ms 74488 KB Output is correct
39 Correct 499 ms 74872 KB Output is correct
40 Correct 608 ms 76248 KB Output is correct
41 Correct 607 ms 76252 KB Output is correct
42 Correct 555 ms 76300 KB Output is correct
43 Correct 614 ms 76252 KB Output is correct