답안 #807666

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
807666 2023-08-04T21:20:20 Z Lobo 자동 인형 (IOI18_doll) C++17
24 / 100
85 ms 17800 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;
	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);
	}
	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]; reverse(all(next));
		vector<int> liga;
		int mult = 1;
		while(next.size() > 1) {
			vector<int> newnext;
			if(next.size()%2 == 1) {
				newnext.pb(cnt);
				x.pb(mult*next.back());
				next.pop_back();
				y.pb(0);
				liga.pb(cnt);
				cnt++;
			}
			while(next.size()) {
				newnext.pb(cnt);
				x.pb(mult*next.back());
				next.pop_back();
				y.pb(mult*next.back());
				next.pop_back();
				cnt++;
			}

			mult = -1;

			next = newnext; reverse(all(next));
		}

		for(auto v : liga) {
			y[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);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Correct 23 ms 8660 KB Output is correct
3 Correct 15 ms 8340 KB Output is correct
4 Correct 2 ms 4948 KB Output is correct
5 Correct 10 ms 6100 KB Output is correct
6 Correct 27 ms 10028 KB Output is correct
7 Correct 3 ms 4948 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Correct 23 ms 8660 KB Output is correct
3 Correct 15 ms 8340 KB Output is correct
4 Correct 2 ms 4948 KB Output is correct
5 Correct 10 ms 6100 KB Output is correct
6 Correct 27 ms 10028 KB Output is correct
7 Correct 3 ms 4948 KB Output is correct
8 Correct 37 ms 10384 KB Output is correct
9 Correct 59 ms 11008 KB Output is correct
10 Correct 56 ms 13324 KB Output is correct
11 Correct 2 ms 4948 KB Output is correct
12 Correct 3 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 23 ms 8660 KB Output is correct
3 Correct 15 ms 8340 KB Output is correct
4 Correct 2 ms 4948 KB Output is correct
5 Correct 10 ms 6100 KB Output is correct
6 Correct 27 ms 10028 KB Output is correct
7 Correct 3 ms 4948 KB Output is correct
8 Correct 37 ms 10384 KB Output is correct
9 Correct 59 ms 11008 KB Output is correct
10 Correct 56 ms 13324 KB Output is correct
11 Correct 2 ms 4948 KB Output is correct
12 Correct 3 ms 4948 KB Output is correct
13 Correct 2 ms 4948 KB Output is correct
14 Correct 73 ms 15624 KB Output is correct
15 Incorrect 40 ms 11424 KB wrong motion
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 4948 KB wrong motion
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4988 KB Output is correct
2 Correct 33 ms 12692 KB Output is correct
3 Correct 32 ms 13728 KB Output is correct
4 Correct 48 ms 16048 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4988 KB Output is correct
2 Correct 33 ms 12692 KB Output is correct
3 Correct 32 ms 13728 KB Output is correct
4 Correct 48 ms 16048 KB Output is correct
5 Incorrect 85 ms 17800 KB wrong motion
6 Halted 0 ms 0 KB -