Submission #85089

# Submission time Handle Problem Language Result Execution time Memory
85089 2018-11-18T12:45:14 Z SirCeness Mechanical Doll (IOI18_doll) C++14
2 / 100
49 ms 10856 KB
#include "doll.h"
#include <bits/stdc++.h>

using namespace std;

int get(vector<int> gider, int *X, int *Y, int *index){
	/*cout << "get -> ";
	for (int i = 0; i < gider.size(); i++) cout << gider[i] << " "; cout << endl;
	*/
	if (gider.size() == 0) return 0;
	bool ayn = true;
	for (int i = 1; i < (int)gider.size(); i++){
		if (gider[i-1] != gider[i]){
			ayn = false;
			break;
		}
	}
	if (ayn) return gider[0];
	
	vector<int> gider1(gider.size()/2);
	vector<int> gider2(gider.size()/2);
	
	for (int i = 0; i < (int)gider.size(); i++){
		if (i & 1){
			gider2[i/2] = gider[i];
		} else gider1[i/2] = gider[i];
	}
	
	gider.clear();
	gider.shrink_to_fit();
	
	//cout << "negative" << endl;
	int sonind = *index;
	int ret = -sonind-1;
	(*index)++;
	X[sonind] = get(gider1, X, Y, index);
	Y[sonind] = get(gider2, X, Y, index);
	return ret;
}

void create_circuit(int M, vector<int> A) {
	
	//cout << "create_circuit(" << M << ");\n";
	
	vector<int> C(M+1);
	for (int i = 0; i < M+1; i++) C[i] = 0;
	C[0] = A[0];
	
	vector<int> gider[M+1];
	
	for (int i = 1; i < (int)A.size(); i++){
		gider[A[i-1]].push_back(A[i]);
	}
	
	int X[40000];
	int Y[40000];
	int index = 0;
	
	for (int i = 1; i <= M; i++){
		C[i] = get(gider[i], X, Y, &index);
	}
	
	vector<int> Xv(index);
	vector<int> Yv(index);
	
	for (int i = 0; i < index; i++){
		Xv[i] = X[i];
		Yv[i] = Y[i];
	}
	/*cout << "C: ";
	for (int i = 0; i < C.size(); i++) cout << C[i] << " "; cout << endl; 
	cout << "X: ";
	for (int i = 0; i < Xv.size(); i++) cout << Xv[i] << " "; cout << endl; 
	cout << "Y: ";
	for (int i = 0; i < Yv.size(); i++) cout << Yv[i] << " "; cout << endl; 
	cout << "index: " << index << endl;
	*/
	
	answer(C, Xv, Yv);
	
}

/*void create_circuit(int M, vector<int> A){
	cout << "create_circuit" << endl;
  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);
}*/
# Verdict Execution time Memory Grader output
1 Correct 1 ms 588 KB Output is correct
2 Correct 36 ms 6712 KB Output is correct
3 Correct 32 ms 5436 KB Output is correct
4 Correct 1 ms 588 KB Output is correct
5 Correct 14 ms 4044 KB Output is correct
6 Correct 49 ms 7988 KB Output is correct
7 Correct 1 ms 588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 588 KB Output is correct
2 Correct 36 ms 6712 KB Output is correct
3 Correct 32 ms 5436 KB Output is correct
4 Correct 1 ms 588 KB Output is correct
5 Correct 14 ms 4044 KB Output is correct
6 Correct 49 ms 7988 KB Output is correct
7 Correct 1 ms 588 KB Output is correct
8 Runtime error 47 ms 10856 KB Execution killed with signal 11
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 588 KB Output is correct
2 Correct 36 ms 6712 KB Output is correct
3 Correct 32 ms 5436 KB Output is correct
4 Correct 1 ms 588 KB Output is correct
5 Correct 14 ms 4044 KB Output is correct
6 Correct 49 ms 7988 KB Output is correct
7 Correct 1 ms 588 KB Output is correct
8 Runtime error 47 ms 10856 KB Execution killed with signal 11
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 588 KB wrong motion
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 588 KB wrong motion
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 588 KB wrong motion
2 Halted 0 ms 0 KB -