답안 #448704

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
448704 2021-07-31T19:55:56 Z Antekb Trobojnica (COCI19_trobojnica) C++14
0 / 110
680 ms 524292 KB
#include<bits/stdc++.h>
#define st first
#define nd second
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<int> V(n);
	vector<pair<int, int> > co(n);
	for(int i=0; i<n; i++)co[i].st=i+1, co[i].nd=(i+1)%n+1;
	string s;
	cin>>s;
	int ile[3]={0, 0, 0};
	for(int i=0; i<n; i++)V[i]=s[i]-'1', ile[V[i]]++;
	if((ile[0]&1)!=(n&1) || (ile[1]&1)!=(n&1)){
		cout<<"NE";
		return 0;
	}
	for(int i=0; i<3; ++i)ile[i]=(n-2-ile[i])/2;
	cout<<"DA\n";
	for(int i=0; i<V.size()-3; i++){
		if(V[i]==V[i+1]){
			V.push_back(V[i]);
			co.push_back(co[i]);
		}
		else if(ile[3-V[i]-V[i+1]]!=0){
			cout<<co[i].st<<" "<<co[i+1].nd<<" "<<4-V[i]-V[i+1]<<"\n";
			co[i+1].st=co[i].st;
			V[i+1]=3-V[i]-V[i+1];
			ile[V[i+1]]--;
		}
		else{
			V.push_back(V[i]);
			co.push_back(co[i]);
		}
	}

}

Compilation message

trobojnica.cpp: In function 'int main()':
trobojnica.cpp:21:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |  for(int i=0; i<V.size()-3; i++){
      |               ~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 296 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 288 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Runtime error 680 ms 524292 KB Execution killed with signal 9
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 296 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 288 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Runtime error 680 ms 524292 KB Execution killed with signal 9
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 296 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 288 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Runtime error 680 ms 524292 KB Execution killed with signal 9