# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
975443 | 2024-05-05T07:56:11 Z | LucaIlie | 자동 인형 (IOI18_doll) | C++17 | 88 ms | 17172 KB |
#include "doll.h" #include <bits/stdc++.h> using namespace std; const int MAX_M = 1e5; const int MAX_L = (1 << 18); int ord[MAX_L]; vector<int> adj[MAX_M + 1]; int switchid( int x ) { return -(x + 1); } void create_circuit( int m, vector<int> a ) { int n = a.size(); vector<int> c( m + 1 ), x, y; if ( n == 16 ) { a.push_back( 0 ); c[0] = a[0]; int p = 4; x.resize( (1 << p) - 1 ); y.resize( (1 << p) - 1 ); for ( int v = 0; v < (1 << (p - 1)) - 1; v++ ) { x[v] = switchid( v * 2 + 1 ); y[v] = switchid( v * 2 + 2 ); } for ( int a = 0; a < (1 << p); a++ ) { int c = 0; for ( int b = 0; b < p; b++ ) { if ((a >> b) & 1 ) c += (1 << (p - 1 - b)); } ord[c] = a; } for ( int j = 0; j < (1 << p); j++ ) { int b = ord[j]; int v = (1 << (p - 1)) - 1 + b / 2; if ( b % 2 == 0 ) x[v] = a[j + 1]; else y[v] = a[j + 1]; } for ( int i = 1; i <= m; i++ ) c[i] = -1; } else { a.push_back( 0 ); reverse( a.begin(), a.end() ); a.push_back( 0 ); reverse( a.begin(), a.end() ); for ( int i = 0; i < a.size() - 1; i++ ) adj[a[i]].push_back( a[i + 1] ); for ( int i = 0; i <= m; i++ ) { if ( adj[i].size() == 0 ) continue; if ( adj[i].size() == 1 ) { c[i] = adj[i][0]; continue; } int p = ceil( log2( adj[i].size())); int r = x.size(); x.resize( r + (1 << p) - 1 ); y.resize( r + (1 << p) - 1 ); c[i] = switchid( r ); for ( int v = 0; v < (1 << (p - 1)) - 1; v++ ) { x[r + v] = switchid( r + v * 2 + 1 ); y[r + v] = switchid( r + v * 2 + 2 ); } for ( int a = 0; a < (1 << p); a++ ) { int c = 0; for ( int b = 0; b < p; b++ ) { if ((a >> b) & 1 ) c += (1 << (p - 1 - b)); } ord[c] = a; } int ind = 0; for ( int j = 0; j < (1 << p); j++ ) { int a = ord[j]; int v = r + (1 << (p - 1)) - 1 + a / 2; if ( j + 1 + adj[i].size() <= (1 << p)) { if ( a % 2 == 0 ) x[v] = switchid( r ); else y[v] = switchid( r ); } else { if ( a % 2 == 0 ) x[v] = adj[i][ind]; else y[v] = adj[i][ind]; ind++; } } } } answer( c, x, y ); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2648 KB | Output is correct |
2 | Correct | 18 ms | 6744 KB | Output is correct |
3 | Correct | 14 ms | 6484 KB | Output is correct |
4 | Correct | 1 ms | 2652 KB | Output is correct |
5 | Correct | 8 ms | 3932 KB | Output is correct |
6 | Correct | 30 ms | 8140 KB | Output is correct |
7 | Correct | 1 ms | 2652 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2648 KB | Output is correct |
2 | Correct | 18 ms | 6744 KB | Output is correct |
3 | Correct | 14 ms | 6484 KB | Output is correct |
4 | Correct | 1 ms | 2652 KB | Output is correct |
5 | Correct | 8 ms | 3932 KB | Output is correct |
6 | Correct | 30 ms | 8140 KB | Output is correct |
7 | Correct | 1 ms | 2652 KB | Output is correct |
8 | Correct | 33 ms | 9252 KB | Output is correct |
9 | Correct | 34 ms | 9584 KB | Output is correct |
10 | Correct | 52 ms | 12972 KB | Output is correct |
11 | Correct | 1 ms | 2652 KB | Output is correct |
12 | Correct | 1 ms | 2652 KB | Output is correct |
13 | Correct | 1 ms | 2652 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2648 KB | Output is correct |
2 | Correct | 18 ms | 6744 KB | Output is correct |
3 | Correct | 14 ms | 6484 KB | Output is correct |
4 | Correct | 1 ms | 2652 KB | Output is correct |
5 | Correct | 8 ms | 3932 KB | Output is correct |
6 | Correct | 30 ms | 8140 KB | Output is correct |
7 | Correct | 1 ms | 2652 KB | Output is correct |
8 | Correct | 33 ms | 9252 KB | Output is correct |
9 | Correct | 34 ms | 9584 KB | Output is correct |
10 | Correct | 52 ms | 12972 KB | Output is correct |
11 | Correct | 1 ms | 2652 KB | Output is correct |
12 | Correct | 1 ms | 2652 KB | Output is correct |
13 | Correct | 1 ms | 2652 KB | Output is correct |
14 | Correct | 70 ms | 14860 KB | Output is correct |
15 | Correct | 34 ms | 8892 KB | Output is correct |
16 | Correct | 52 ms | 12132 KB | Output is correct |
17 | Correct | 1 ms | 2648 KB | Output is correct |
18 | Correct | 1 ms | 2652 KB | Output is correct |
19 | Correct | 1 ms | 2712 KB | Output is correct |
20 | Correct | 59 ms | 12352 KB | Output is correct |
21 | Correct | 1 ms | 2652 KB | Output is correct |
22 | Correct | 1 ms | 2904 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2648 KB | Output is correct |
2 | Correct | 1 ms | 2904 KB | Output is correct |
3 | Correct | 1 ms | 2652 KB | Output is correct |
4 | Correct | 1 ms | 2648 KB | Output is correct |
5 | Correct | 1 ms | 2652 KB | Output is correct |
6 | Correct | 1 ms | 2652 KB | Output is correct |
7 | Correct | 1 ms | 2652 KB | Output is correct |
8 | Correct | 1 ms | 2652 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Partially correct | 1 ms | 2652 KB | Output is partially correct |
2 | Correct | 35 ms | 9768 KB | Output is correct |
3 | Partially correct | 59 ms | 12248 KB | Output is partially correct |
4 | Partially correct | 65 ms | 13124 KB | Output is partially correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Partially correct | 1 ms | 2652 KB | Output is partially correct |
2 | Correct | 35 ms | 9768 KB | Output is correct |
3 | Partially correct | 59 ms | 12248 KB | Output is partially correct |
4 | Partially correct | 65 ms | 13124 KB | Output is partially correct |
5 | Partially correct | 71 ms | 14648 KB | Output is partially correct |
6 | Partially correct | 78 ms | 15596 KB | Output is partially correct |
7 | Partially correct | 76 ms | 15824 KB | Output is partially correct |
8 | Partially correct | 79 ms | 15828 KB | Output is partially correct |
9 | Partially correct | 59 ms | 12976 KB | Output is partially correct |
10 | Partially correct | 86 ms | 17172 KB | Output is partially correct |
11 | Partially correct | 88 ms | 16860 KB | Output is partially correct |
12 | Partially correct | 59 ms | 12868 KB | Output is partially correct |
13 | Partially correct | 51 ms | 11108 KB | Output is partially correct |
14 | Partially correct | 52 ms | 11000 KB | Output is partially correct |
15 | Partially correct | 48 ms | 10540 KB | Output is partially correct |
16 | Partially correct | 2 ms | 2908 KB | Output is partially correct |
17 | Partially correct | 42 ms | 10348 KB | Output is partially correct |
18 | Partially correct | 48 ms | 10224 KB | Output is partially correct |
19 | Partially correct | 45 ms | 11332 KB | Output is partially correct |
20 | Partially correct | 64 ms | 13996 KB | Output is partially correct |
21 | Partially correct | 85 ms | 14916 KB | Output is partially correct |
22 | Partially correct | 63 ms | 12756 KB | Output is partially correct |