답안 #858884

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
858884 2023-10-09T10:47:10 Z waldi 자동 인형 (IOI18_doll) C++17
16 / 100
60 ms 12516 KB
#include "doll.h"
#include <bits/stdc++.h>
#define FOR(i,p,k) for(int i=(p);i<=(k);++i)
#define REP(i,n) FOR(i,0,(n)-1)
#define ssize(x) (int(x.size()))
using namespace std;

void create_circuit(int m, vector<int> a){
	int n = a.size();
	
	vector<vector<int>> g(m+1);
	REP(i, n){
		if(i) g[a[i-1]].emplace_back(a[i]);
		else g[0].emplace_back(a[i]);
	}
	g[a.back()].emplace_back(0);
	
	int maks = 0;
	FOR(i, 0, m) maks = max(maks, ssize(g[i]));
	if(maks <= 4){
		vector<int> c(m+1, 0);
		int it = 0;
		vector<int> x, y;
		auto nowy = [&](){
			x.emplace_back(0);
			y.emplace_back(0);
			++it;
		};
		
		FOR(i, 0, m) if(g[i].size()){
			if(ssize(g[i]) == 1){
				c[i] = g[i][0];
			}
			if(ssize(g[i]) == 2){
				nowy();
				c[i] = -(it-1)-1;
				x[it-1] = g[i][0];
				y[it-1] = g[i][1];
			}
			if(ssize(g[i]) == 3){
				nowy(), nowy(), nowy();
				c[i] = -(it-1)-1;
				x[it-1] = -(it-2)-1;
				y[it-1] = -(it-3)-1;
				x[it-2] = -(it-1)-1;
				y[it-2] = g[i][1];
				x[it-3] = g[i][0];
				y[it-3] = g[i][2];
			}
			if(ssize(g[i]) == 4){
				nowy(), nowy(), nowy();
				c[i] = -(it-1)-1;
				x[it-1] = -(it-2)-1;
				y[it-1] = -(it-3)-1;
				x[it-2] = g[i][0];
				y[it-2] = g[i][2];
				x[it-3] = g[i][1];
				y[it-3] = g[i][3];
			}
		}
		
		/*printf("c: ");
		for(int i : c) printf("%d ", i);
		printf("\n");
		
		printf("x: ");
		for(int i : x) printf("%d ", i);
		printf("\n");
		
		printf("y: ");
		for(int i : y) printf("%d ", i);
		printf("\n");*/
		
		answer(c, x, y);
		return;
	}
	
	
	int N = 1;
	while(N < n) N <<= 1;
	
	
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 19 ms 6492 KB Output is correct
3 Correct 15 ms 5212 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 8 ms 3932 KB Output is correct
6 Correct 23 ms 7772 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 19 ms 6492 KB Output is correct
3 Correct 15 ms 5212 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 8 ms 3932 KB Output is correct
6 Correct 23 ms 7772 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 33 ms 7384 KB Output is correct
9 Correct 34 ms 9864 KB Output is correct
10 Correct 52 ms 12516 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 19 ms 6492 KB Output is correct
3 Correct 15 ms 5212 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 8 ms 3932 KB Output is correct
6 Correct 23 ms 7772 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 33 ms 7384 KB Output is correct
9 Correct 34 ms 9864 KB Output is correct
10 Correct 52 ms 12516 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 60 ms 12488 KB Output is correct
15 Correct 33 ms 6816 KB Output is correct
16 Correct 50 ms 10080 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 56 ms 12192 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Wrong Answer: answered not exactly once
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Wrong Answer: answered not exactly once
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Wrong Answer: answered not exactly once
2 Halted 0 ms 0 KB -