Submission #800811

# Submission time Handle Problem Language Result Execution time Memory
800811 2023-08-01T21:41:40 Z biank Mechanical Doll (IOI18_doll) C++14
0 / 100
36 ms 8400 KB
#include "doll.h"
#include <bits/stdc++.h>

using namespace std;

#define SIZE(x) (int)x.size()

void create_circuit(int M, vector<int> A) {
	
	int N = SIZE(A);
	
	if (N == 16) {
		vector <int> C(M+1), X, Y;
		for (int i=-2; i>=-14; i-=2) {
			X.push_back(i);
			Y.push_back(i-1);
		}
		X.push_back(A[0]);
		X.push_back(A[4]);
		X.push_back(A[2]);
		X.push_back(A[6]);
		X.push_back(A[1]);
		X.push_back(A[5]);
		X.push_back(A[3]);
		X.push_back(A[7]);
		Y.push_back(A[8]);
		Y.push_back(A[12]);
		Y.push_back(A[10]);
		Y.push_back(A[14]);
		Y.push_back(A[9]);
		Y.push_back(A[13]);
		Y.push_back(A[11]);
		Y.push_back(A[15]);
		C[0] = -1;
		C[A[15]] = 0;
		answer(C, X, Y);
		return;
	}
	
	vector <int> C(M+1);
	vector <int> X, Y;
	if (M == 1) {
		X.resize(N-1);
		Y.resize(N-1);
		
  C[0] = 1;
  if (N == 1) {
	  C[1] = 0;
	  answer(C,X,Y);
	  return;
	}
	
	if (N == 2) {
		C[1] = -1;
		X[0] = 1;
		Y[0] = 0;
		answer(C,X,Y);
		return;
	}
	
	C[1] = -1;
	X[0] = 1;
	Y[0] = -2;
	
	
	for (int i=1; i<N-2; i++) {
		X[i] = -i;
		Y[i] = -i-2;
		//cerr << X[i] << ' ' << Y[i] << endl;
	}
	
	X[N-2] = -N+2;
	Y[N-2] = 0;
	} else {
	A.push_back(0);
	map <int, vector <int>> next;
	for (int i=0; i<N; i++) {
		next[A[i]].push_back(A[i+1]);
		//Scerr << A[i] << ' ' << A[i+1] << endl;
	}
	
	C[0] = A[0];
	int j = 0;
	for (auto &x:next) {
		int a = x.first;
		vector <int> n = x.second;
		int S = SIZE(n);
		if (S == 1) {
			C[a] = n[0];
			continue;
		}
		if (S == 2) {
			C[a] = --j;
			X.push_back(n[0]);
			Y.push_back(n[1]);
			continue;
		}
		if (S == 4) {
			C[a] = --j;
			X.push_back(--j);
			Y.push_back(--j);
			X.push_back(n[0]);
			Y.push_back(n[2]);
			X.push_back(n[1]);
			Y.push_back(n[3]);
			continue;
		}
		if (S == 3) {
			C[a] = --j;
			X.push_back(--j);
			Y.push_back(--j);
			X.push_back(n[0]);
			Y.push_back(n[1]);
			X.push_back(j+2);
			Y.push_back(n[2]);
		}
	}
	
}
  
  
  /*for (int i=0; i<=M; i++) {
	  cerr << C[i] << " ";
  }
  cerr << endl;*/

  
  answer(C, X, Y);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 36 ms 8400 KB Output is correct
3 Correct 35 ms 8164 KB Output is correct
4 Incorrect 0 ms 212 KB wrong motion
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 36 ms 8400 KB Output is correct
3 Correct 35 ms 8164 KB Output is correct
4 Incorrect 0 ms 212 KB wrong motion
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 36 ms 8400 KB Output is correct
3 Correct 35 ms 8164 KB Output is correct
4 Incorrect 0 ms 212 KB wrong motion
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB wrong motion
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 30 ms 4408 KB over 20000000 inversions
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 30 ms 4408 KB over 20000000 inversions
3 Halted 0 ms 0 KB -