Submission #858882

# Submission time Handle Problem Language Result Execution time Memory
858882 2023-10-09T10:42:53 Z waldi Mechanical Doll (IOI18_doll) C++17
2 / 100
32 ms 8428 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]);
	}
	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;
	
	
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 500 KB Output is correct
2 Correct 18 ms 6956 KB Output is correct
3 Correct 15 ms 5724 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 8 ms 3932 KB Output is correct
6 Correct 25 ms 8428 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 500 KB Output is correct
2 Correct 18 ms 6956 KB Output is correct
3 Correct 15 ms 5724 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 8 ms 3932 KB Output is correct
6 Correct 25 ms 8428 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Incorrect 32 ms 8268 KB wrong motion
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 500 KB Output is correct
2 Correct 18 ms 6956 KB Output is correct
3 Correct 15 ms 5724 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 8 ms 3932 KB Output is correct
6 Correct 25 ms 8428 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Incorrect 32 ms 8268 KB wrong motion
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Wrong Answer: answered not exactly once
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Wrong Answer: answered not exactly once
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Wrong Answer: answered not exactly once
2 Halted 0 ms 0 KB -