답안 #711800

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
711800 2023-03-17T14:20:57 Z willychan Checker (COCI19_checker) C++14
0 / 110
311 ms 49544 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include<bits/extc++.h>
//__gnu_pbds


vector<map<int,int> > edge;
vector<int> rt;
vector<int> lt;

vector<bool> vis;
int n;
bool par = 1;
void dfs(int cur){
	if(vis[cur]) return ;
	n--;
	//cout<<cur<<":\n";
	vis[cur]=1;
	int a = rt[cur];
	int b = lt[cur];
	int c1 = edge[a][b];
	int c2 = edge[a][cur];
	int c3 = edge[b][cur];
	if(c1==c2 || c2==c3 || c3==c1) par = 0;
	rt[b] = a;
	lt[a] = b;
	/*for(int i=0;i<lt.size();i++){
		cout<<i<<":"<<lt[i]<<" "<<rt[i]<<"\n";
	}*/
	if(edge[rt[a]].count(lt[a])) dfs(a);
	if(edge[rt[b]].count(lt[b])) dfs(b);
}

int main(){
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int t;cin>>t;
	cin>>n;
	rt.resize(n);
	lt.resize(n);
	edge.resize(n);
	vis.resize(n);
	string s;cin>>s;	
	for(int i=0;i<n;i++){
		edge[i][(i+1)%n] = s[i]-'0';
		edge[(i+1)%n][i] = s[i]-'0';
		rt[i] = (i+1)%n;
		lt[(i+1)%n] = i;
	}
	for(int i=0;i<n-3;i++){
		int a,b,c;cin>>a>>b>>c;
		a--;b--;
		edge[a][b] = c;
		edge[b][a] = c;
	}
	
	for(int i=0;i<n;i++){
		if(edge[rt[i]].count(lt[i])) dfs(i);
	}
	/*if(n>2){
		cout<<"neispravna triangulacija\n";
		return 0;
	}*/
	if(par){
		cout<<"tocno\n";
	}else{
		cout<<"neispravno bojenje\n";
	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Incorrect 1 ms 280 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Incorrect 1 ms 280 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 294 ms 48976 KB Output is correct
2 Correct 311 ms 49520 KB Output is correct
3 Incorrect 258 ms 49496 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 303 ms 49036 KB Output is correct
2 Correct 265 ms 49544 KB Output is correct
3 Incorrect 275 ms 49492 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Incorrect 1 ms 280 KB Output isn't correct
4 Halted 0 ms 0 KB -