# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
335308 | 2020-12-11T22:46:54 Z | CaroLinda | Trobojnica (COCI19_trobojnica) | C++14 | 2000 ms | 2412 KB |
#include <bits/stdc++.h> using namespace std ; int N ; int freq[3] ; int main() { scanf("%d", &N) ; vector<int> color(N) , nxt(N) ; for(int i = 0 ; i < N ; i++ ) { char c ; scanf(" %c", &c ) ; color[i] = c-'1' ; freq[ color[i] ]++ ; nxt[i] = (i == N-1) ? 0 : (i+1) ; } for(int i = 0 ; i < 3 ; i++ ) if(freq[i] > N-2 || (N-2-freq[i])&1 ) { printf("NE\n") ; return 0 ; } printf("DA\n") ; vector< tuple<int,int,int> > ans ; int cur = 1 ; while(N > 3 ) { int mostFrequent = (freq[0] > freq[1] ) ? 0 : 1 ; mostFrequent = (freq[mostFrequent] > freq[2] ) ? mostFrequent : 2 ; if( color[cur] != color[ nxt[cur] ] && (color[cur] == mostFrequent || color[nxt[cur] ] == mostFrequent) ) { // printf("%d %d %d %d %d\n", cur, nxt[cur], nxt[nxt[cur] ] , color[cur] , color[nxt[cur] ] ) ; freq[ color[cur] ]-- ; freq[ color[nxt[cur] ] ]-- ; color[cur] = 3 - color[cur] - color[ nxt[cur] ] ; nxt[cur] = nxt[ nxt[cur] ] ; ans.push_back( make_tuple(cur, nxt[cur] , color[cur] ) ) ; freq[color[cur] ]++ ; N-- ; } else cur = nxt[cur] ; } for(auto e : ans ) printf("%d %d %d\n", get<0>(e)+1 , get<1>(e)+1, get<2>(e)+1 ) ; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Correct | 1 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 384 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 1 ms | 364 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Correct | 1 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 384 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 1 ms | 364 KB | Output is correct |
11 | Correct | 1 ms | 364 KB | Output is correct |
12 | Correct | 1 ms | 364 KB | Output is correct |
13 | Correct | 1 ms | 364 KB | Output is correct |
14 | Correct | 1 ms | 384 KB | Output is correct |
15 | Correct | 1 ms | 256 KB | Output is correct |
16 | Correct | 1 ms | 364 KB | Output is correct |
17 | Correct | 1 ms | 364 KB | Output is correct |
18 | Correct | 1 ms | 384 KB | Output is correct |
19 | Correct | 1 ms | 364 KB | Output is correct |
20 | Correct | 1 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Correct | 1 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 384 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 1 ms | 364 KB | Output is correct |
11 | Correct | 1 ms | 364 KB | Output is correct |
12 | Correct | 1 ms | 364 KB | Output is correct |
13 | Correct | 1 ms | 364 KB | Output is correct |
14 | Correct | 1 ms | 384 KB | Output is correct |
15 | Correct | 1 ms | 256 KB | Output is correct |
16 | Correct | 1 ms | 364 KB | Output is correct |
17 | Correct | 1 ms | 364 KB | Output is correct |
18 | Correct | 1 ms | 384 KB | Output is correct |
19 | Correct | 1 ms | 364 KB | Output is correct |
20 | Correct | 1 ms | 384 KB | Output is correct |
21 | Execution timed out | 2084 ms | 2412 KB | Time limit exceeded |
22 | Halted | 0 ms | 0 KB | - |