답안 #515684

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
515684 2022-01-19T13:09:01 Z ymm 자동 인형 (IOI18_doll) C++17
100 / 100
105 ms 10868 KB
///
///   Oh? You're approaching me?
///

#include <bits/stdc++.h>
#define Loop(x,l,r) for(ll x = ll(l); x < ll(r); ++x)
#define LoopR(x,l,r) for(ll x = ll(r)-1; x >= ll(l); --x)
#define Kill(x) exit((cout << (x) << '\n', 0))
typedef long long ll;
typedef std::pair<int,int> pii;
typedef std::pair<ll,ll> pll;
using namespace std;

#include "doll.h"

const int N = 1e6+10;
int n, lg, cnt;
int x[N], y[N];
bool sd[N];
vector<int> C;

//void answer(vector<int> C, vector<int> X, vector<int> Y){
//	for(int x : C) cout << x << ' '; cout << '\n';
//	for(int x : X) cout << x << ' '; cout << '\n';
//	for(int x : Y) cout << x << ' '; cout << '\n';
//}

int make(int sz){
	if(sz==1) return 0;
	int i = cnt++;
	x[i] = make(sz/2);
	y[i] = make(sz/2);
	return ~i;
}

int& find(int v=0){
	return (sd[v]=!sd[v])? (x[v]?find(~x[v]):x[v]): (y[v]?find(~y[v]):y[v]);
}

void create_circuit(int m, vector<int> a)
{
	n = a.size();
	C.resize(m+1);
	C[0] = a[0];
	if(n==1){
		answer(C, {}, {});
		return;
	}
	Loop(i,1,m+1) C[i] = -1;
	for(int z=1; z<n; z*=2) ++lg;
	Loop(i,0,lg-1) y[i]=~(i+1);
	cnt = lg;
	for(int i=0,z=1<<(lg-1); z; ++i,z/=2){
		x[i] = (n-1)&z? make(z): -1;
	}
	Loop(i,1,n) find() = a[i];
	auto X = vector<int>(x,x+cnt);
	auto Y = vector<int>(y,y+cnt);
	answer(C,X,Y);
}

//int main(){
//	create_circuit(10, {5});
//}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 300 KB Output is correct
2 Correct 34 ms 4552 KB Output is correct
3 Correct 33 ms 4168 KB Output is correct
4 Correct 0 ms 304 KB Output is correct
5 Correct 9 ms 1456 KB Output is correct
6 Correct 52 ms 6136 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 300 KB Output is correct
2 Correct 34 ms 4552 KB Output is correct
3 Correct 33 ms 4168 KB Output is correct
4 Correct 0 ms 304 KB Output is correct
5 Correct 9 ms 1456 KB Output is correct
6 Correct 52 ms 6136 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 66 ms 7200 KB Output is correct
9 Correct 73 ms 7656 KB Output is correct
10 Correct 97 ms 10868 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 300 KB Output is correct
2 Correct 34 ms 4552 KB Output is correct
3 Correct 33 ms 4168 KB Output is correct
4 Correct 0 ms 304 KB Output is correct
5 Correct 9 ms 1456 KB Output is correct
6 Correct 52 ms 6136 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 66 ms 7200 KB Output is correct
9 Correct 73 ms 7656 KB Output is correct
10 Correct 97 ms 10868 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 105 ms 10480 KB Output is correct
15 Correct 61 ms 6884 KB Output is correct
16 Correct 96 ms 10344 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 97 ms 10668 KB Output is correct
21 Correct 1 ms 304 KB Output is correct
22 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 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 308 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 0 ms 304 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 56 ms 6468 KB Output is correct
3 Correct 60 ms 6492 KB Output is correct
4 Correct 104 ms 9776 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 56 ms 6468 KB Output is correct
3 Correct 60 ms 6492 KB Output is correct
4 Correct 104 ms 9776 KB Output is correct
5 Correct 98 ms 10276 KB Output is correct
6 Correct 92 ms 10052 KB Output is correct
7 Correct 94 ms 10076 KB Output is correct
8 Correct 94 ms 9896 KB Output is correct
9 Correct 56 ms 6456 KB Output is correct
10 Correct 90 ms 9772 KB Output is correct
11 Correct 92 ms 9780 KB Output is correct
12 Correct 66 ms 6452 KB Output is correct
13 Correct 64 ms 6680 KB Output is correct
14 Correct 60 ms 6724 KB Output is correct
15 Correct 63 ms 6728 KB Output is correct
16 Correct 3 ms 572 KB Output is correct
17 Correct 57 ms 6428 KB Output is correct
18 Correct 53 ms 6492 KB Output is correct
19 Correct 64 ms 6496 KB Output is correct
20 Correct 102 ms 9896 KB Output is correct
21 Correct 87 ms 9764 KB Output is correct
22 Correct 88 ms 9768 KB Output is correct