답안 #222420

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
222420 2020-04-13T07:04:37 Z jamielim Checker (COCI19_checker) C++14
110 / 110
1578 ms 100444 KB
#include <bits/stdc++.h>
using namespace std;

int main(){
	int t,n;
	scanf("%d%d",&t,&n);
	char c[n+5];
	scanf("%s",c);
	pair<pair<int,int>,int> p[n-3];
	for(int i=0;i<n-3;i++){
		scanf("%d%d%d",&p[i].first.first,&p[i].first.second,&p[i].second);
	}
	map<pair<int,int>,int> m;
	set<pair<int,int> > adj[n+5];
	for(int i=0;i<n;i++){
		int x=i+1,y=i+2; if(y==n+1)y=1;
		m[make_pair(x,y)]=c[i]-'0';m[make_pair(y,x)]=c[i]-'0';
		adj[x].insert(make_pair(y,c[i]-'0'));
		adj[y].insert(make_pair(x,c[i]-'0'));
	}
	for(int i=0;i<n-3;i++)m[p[i].first]=p[i].second;
	for(int i=0;i<n-3;i++){
		m[p[i].first]=p[i].second;m[make_pair(p[i].first.second,p[i].first.first)]=p[i].second;
		adj[p[i].first.first].insert(make_pair(p[i].first.second,p[i].second));
		adj[p[i].first.second].insert(make_pair(p[i].first.first,p[i].second));
	}
	bool col=1;
	queue<int> q;
	for(int i=1;i<=n;i++){
		if((int)adj[i].size()==2)q.push(i);
	}
	while(!q.empty()){
		int cur=q.front();q.pop();
		//printf("%d\n",cur);
		if((int)adj[cur].size()!=2)continue;
		pair<int,int> x=(*adj[cur].begin()),y=(*(++adj[cur].begin()));
		if(m.find(make_pair(x.first,y.first))==m.end()){
			printf("neispravna triangulacija");
			return 0;
		}
		int z=m[make_pair(x.first,y.first)];
		if(z!=x.second&&z!=y.second&&x.second!=y.second){
		}else{
			col=0;
		}
		adj[x.first].erase(make_pair(cur,x.second));
		adj[y.first].erase(make_pair(cur,y.second));
		m.erase(make_pair(x.first,cur));
		m.erase(make_pair(cur,x.first));
		m.erase(make_pair(y.first,cur));
		m.erase(make_pair(cur,y.first));
		adj[cur].clear();
		if((int)adj[x.first].size()==2)q.push(x.first);
		if((int)adj[y.first].size()==2)q.push(y.first);
	}
	int sum=0;
	for(int i=1;i<=n;i++){
		sum+=adj[i].size();
	}
	if(sum!=2)printf("neispravna triangulacija");
	else if(!col)printf("neispravno bojenje");
	else printf("tocno");
}

Compilation message

checker.cpp: In function 'int main()':
checker.cpp:6:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d",&t,&n);
  ~~~~~^~~~~~~~~~~~~~
checker.cpp:8:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%s",c);
  ~~~~~^~~~~~~~
checker.cpp:11:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d%d",&p[i].first.first,&p[i].first.second,&p[i].second);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 512 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 512 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 10 ms 1280 KB Output is correct
9 Correct 10 ms 1280 KB Output is correct
10 Correct 8 ms 1280 KB Output is correct
11 Correct 8 ms 1280 KB Output is correct
12 Correct 10 ms 1280 KB Output is correct
13 Correct 10 ms 1280 KB Output is correct
14 Correct 10 ms 1280 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1568 ms 100084 KB Output is correct
2 Correct 1578 ms 100260 KB Output is correct
3 Correct 1419 ms 100344 KB Output is correct
4 Correct 1050 ms 100216 KB Output is correct
5 Correct 1052 ms 100216 KB Output is correct
6 Correct 1341 ms 99960 KB Output is correct
7 Correct 1478 ms 99968 KB Output is correct
8 Correct 1198 ms 99984 KB Output is correct
9 Correct 1124 ms 100096 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1519 ms 100280 KB Output is correct
2 Correct 1549 ms 100344 KB Output is correct
3 Correct 1525 ms 100216 KB Output is correct
4 Correct 1516 ms 100444 KB Output is correct
5 Correct 1530 ms 100344 KB Output is correct
6 Correct 1344 ms 100088 KB Output is correct
7 Correct 1372 ms 99988 KB Output is correct
8 Correct 1382 ms 100088 KB Output is correct
9 Correct 1370 ms 99960 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 512 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 10 ms 1280 KB Output is correct
9 Correct 10 ms 1280 KB Output is correct
10 Correct 8 ms 1280 KB Output is correct
11 Correct 8 ms 1280 KB Output is correct
12 Correct 10 ms 1280 KB Output is correct
13 Correct 10 ms 1280 KB Output is correct
14 Correct 10 ms 1280 KB Output is correct
15 Correct 1568 ms 100084 KB Output is correct
16 Correct 1578 ms 100260 KB Output is correct
17 Correct 1419 ms 100344 KB Output is correct
18 Correct 1050 ms 100216 KB Output is correct
19 Correct 1052 ms 100216 KB Output is correct
20 Correct 1341 ms 99960 KB Output is correct
21 Correct 1478 ms 99968 KB Output is correct
22 Correct 1198 ms 99984 KB Output is correct
23 Correct 1124 ms 100096 KB Output is correct
24 Correct 1519 ms 100280 KB Output is correct
25 Correct 1549 ms 100344 KB Output is correct
26 Correct 1525 ms 100216 KB Output is correct
27 Correct 1516 ms 100444 KB Output is correct
28 Correct 1530 ms 100344 KB Output is correct
29 Correct 1344 ms 100088 KB Output is correct
30 Correct 1372 ms 99988 KB Output is correct
31 Correct 1382 ms 100088 KB Output is correct
32 Correct 1370 ms 99960 KB Output is correct
33 Correct 1533 ms 100216 KB Output is correct
34 Correct 1530 ms 100244 KB Output is correct
35 Correct 1444 ms 100088 KB Output is correct
36 Correct 1057 ms 100216 KB Output is correct
37 Correct 1515 ms 100088 KB Output is correct
38 Correct 1523 ms 100272 KB Output is correct
39 Correct 1504 ms 100088 KB Output is correct
40 Correct 1346 ms 99968 KB Output is correct
41 Correct 1358 ms 99964 KB Output is correct
42 Correct 1126 ms 100096 KB Output is correct
43 Correct 1415 ms 100024 KB Output is correct