답안 #85090

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
85090 2018-11-18T12:56:11 Z SirCeness 자동 인형 (IOI18_doll) C++14
2 / 100
67 ms 9280 KB
#include "doll.h"
#include <bits/stdc++.h>

using namespace std;

int get(vector<int> gider, int *X, int *Y, int *index, int st, int at){
	/*cout << "get -> ";
	for (int i = st; i < gider.size(); i += at) cout << gider[i] << " "; cout << endl;
	*/
	if (gider.size() == 0) return 0;
	bool ayn = true;
	for (int i = st+at; i < (int)gider.size(); i += at){
		if (gider[i-at] != gider[i]){
			ayn = false;
			break;
		}
	}
	if (ayn) return gider[st];
	
	//cout << "negative" << endl;
	int sonind = *index;
	int ret = -sonind-1;
	(*index)++;
	X[sonind] = get(gider, X, Y, index, st, at*2);
	Y[sonind] = get(gider, X, Y, index, st+at, at*2);
	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[2*A.size()];
	int Y[2*A.size()];
	int index = 0;
	
	for (int i = 1; i <= M; i++){
		//cout << "C[" << i << "] -> ";
		C[i] = get(gider[i], X, Y, &index, 0, 1);
	}
	
	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);
}*/
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 40 ms 7336 KB Output is correct
3 Correct 46 ms 6192 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 14 ms 3788 KB Output is correct
6 Correct 55 ms 9280 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 40 ms 7336 KB Output is correct
3 Correct 46 ms 6192 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 14 ms 3788 KB Output is correct
6 Correct 55 ms 9280 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Incorrect 67 ms 9236 KB wrong motion
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 40 ms 7336 KB Output is correct
3 Correct 46 ms 6192 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 14 ms 3788 KB Output is correct
6 Correct 55 ms 9280 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Incorrect 67 ms 9236 KB wrong motion
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB state 'Y'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB wrong motion
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB wrong motion
2 Halted 0 ms 0 KB -