답안 #815790

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
815790 2023-08-08T23:18:27 Z Lobo 자동 인형 (IOI18_doll) C++17
100 / 100
54 ms 16820 KB
#include "doll.h"
#include<bits/stdc++.h>
using namespace std;
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define int long long

const int inf = 1e18+10;
const int maxn = 2e5+10;

int n, m;
vector<int> g[maxn];

void create_circuit(int32_t M, std::vector<int32_t> A) {
	// int N = A.size();
	// std::vector<int> C(M + 1);
	// C[0] = -1;
	// for (int i = 1; i <= M; ++i) {
	// C[i] = 1;
	// }
	// std::vector<int> X(N), Y(N);
	// for (int k = 0; k < N; ++k) {
	// X[k] = Y[k] = A[k];
	// }
	// answer(C, X, Y);
	n = A.size();
	m = M;
	vector<int32_t> c(m+1),x,y;
	vector<int> next;
	for(int i = -1; i < n; i++) {
		int u,v;
		if(i == -1) u = 0, v = A[0];
		else if(i == n-1) u = A[n-1], v = 0;
		else u = A[i], v = A[i+1];

		// g[u].pb(v);
		next.pb(v);
	}

	int cnt = 1;
	vector<int> liga;
	int mult = 1;
	while(next.size() > 1) {
		vector<int> newnext;

		for(int i = 0; i < next.size()/2; i++) {
			newnext.pb(cnt);
			x.pb(mult*next[i]);
			y.pb(mult*next[i+next.size()/2]);
			cnt++;
		}
		if(next.size()%2 == 1) {
			newnext.pb(cnt);
			y.pb(mult*next.back());
			x.pb(0);
			liga.pb(cnt);
			cnt++;
		}
		mult = -1;

		next = newnext;
	}

	for(auto v : liga) {
		x[v-1] = -next[0];
	}

	for(int i = 0; i <= m; i++) {
		c[i] = -next[0];
	}


	// int cnt = 1;
	// for(int i = 0; i <= m; i++) {
	// 	if(g[i].size() == 0) {
	// 		c[i] = i;
	// 		continue;
	// 	}
	// 	if(g[i].size() == 1) {
	// 		c[i] = g[i][0];
	// 		continue;
	// 	}

	// 	vector<int> next = g[i];
	// 	vector<int> liga;
	// 	int mult = 1;
	// 	while(next.size() > 1) {
	// 		vector<int> newnext;

	// 		for(int i = 0; i < next.size()/2; i++) {
	// 			newnext.pb(cnt);
	// 			x.pb(mult*next[i]);
	// 			y.pb(mult*next[i+next.size()/2]);
	// 			cnt++;
	// 		}
	// 		if(next.size()%2 == 1) {
	// 			newnext.pb(cnt);
	// 			y.pb(mult*next.back());
	// 			x.pb(0);
	// 			liga.pb(cnt);
	// 			cnt++;
	// 		}
	// 		mult = -1;

	// 		next = newnext;
	// 	}

	// 	for(auto v : liga) {
	// 		x[v-1] = -next[0];
	// 	}

	// 	c[i] = -next[0];

	// 	// cout << i << " " << c[i] << " " << cnt << endl;
	// }

	// for(int i = 0; i <= m; i++) {
	// 	cout << i << " -> " << c[i] << endl;
	// }

	// for(int i = 0; i < x.size(); i++) {
	// 	cout << -(i+1) << " -> " << x[i] << " " << y[i] << endl;
	// }

	answer(c,x,y);
}

Compilation message

doll.cpp: In function 'void create_circuit(int32_t, std::vector<int>)':
doll.cpp:34:7: warning: variable 'u' set but not used [-Wunused-but-set-variable]
   34 |   int u,v;
      |       ^
doll.cpp:49:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |   for(int i = 0; i < next.size()/2; i++) {
      |                  ~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Correct 24 ms 10320 KB Output is correct
3 Correct 30 ms 9792 KB Output is correct
4 Correct 2 ms 4948 KB Output is correct
5 Correct 10 ms 6100 KB Output is correct
6 Correct 38 ms 11552 KB Output is correct
7 Correct 2 ms 4948 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Correct 24 ms 10320 KB Output is correct
3 Correct 30 ms 9792 KB Output is correct
4 Correct 2 ms 4948 KB Output is correct
5 Correct 10 ms 6100 KB Output is correct
6 Correct 38 ms 11552 KB Output is correct
7 Correct 2 ms 4948 KB Output is correct
8 Correct 36 ms 13532 KB Output is correct
9 Correct 41 ms 13544 KB Output is correct
10 Correct 54 ms 16820 KB Output is correct
11 Correct 3 ms 4948 KB Output is correct
12 Correct 2 ms 4948 KB Output is correct
13 Correct 2 ms 4948 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Correct 24 ms 10320 KB Output is correct
3 Correct 30 ms 9792 KB Output is correct
4 Correct 2 ms 4948 KB Output is correct
5 Correct 10 ms 6100 KB Output is correct
6 Correct 38 ms 11552 KB Output is correct
7 Correct 2 ms 4948 KB Output is correct
8 Correct 36 ms 13532 KB Output is correct
9 Correct 41 ms 13544 KB Output is correct
10 Correct 54 ms 16820 KB Output is correct
11 Correct 3 ms 4948 KB Output is correct
12 Correct 2 ms 4948 KB Output is correct
13 Correct 2 ms 4948 KB Output is correct
14 Correct 51 ms 16348 KB Output is correct
15 Correct 37 ms 12928 KB Output is correct
16 Correct 51 ms 15676 KB Output is correct
17 Correct 3 ms 4996 KB Output is correct
18 Correct 2 ms 4948 KB Output is correct
19 Correct 2 ms 4948 KB Output is correct
20 Correct 52 ms 16600 KB Output is correct
21 Correct 2 ms 4948 KB Output is correct
22 Correct 2 ms 4948 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Correct 2 ms 4948 KB Output is correct
3 Correct 2 ms 4948 KB Output is correct
4 Correct 2 ms 4948 KB Output is correct
5 Correct 2 ms 4948 KB Output is correct
6 Correct 2 ms 4948 KB Output is correct
7 Correct 2 ms 4948 KB Output is correct
8 Correct 2 ms 4948 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Correct 30 ms 11588 KB Output is correct
3 Correct 34 ms 11588 KB Output is correct
4 Correct 44 ms 13456 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Correct 30 ms 11588 KB Output is correct
3 Correct 34 ms 11588 KB Output is correct
4 Correct 44 ms 13456 KB Output is correct
5 Correct 49 ms 14052 KB Output is correct
6 Correct 48 ms 13988 KB Output is correct
7 Correct 48 ms 14064 KB Output is correct
8 Correct 46 ms 13736 KB Output is correct
9 Correct 31 ms 11652 KB Output is correct
10 Correct 46 ms 13748 KB Output is correct
11 Correct 45 ms 13508 KB Output is correct
12 Correct 32 ms 11588 KB Output is correct
13 Correct 32 ms 11836 KB Output is correct
14 Correct 33 ms 11964 KB Output is correct
15 Correct 33 ms 12128 KB Output is correct
16 Correct 3 ms 5204 KB Output is correct
17 Correct 32 ms 11092 KB Output is correct
18 Correct 31 ms 11588 KB Output is correct
19 Correct 31 ms 11656 KB Output is correct
20 Correct 45 ms 13580 KB Output is correct
21 Correct 45 ms 13500 KB Output is correct
22 Correct 48 ms 13548 KB Output is correct