제출 #85088

#제출 시각아이디문제언어결과실행 시간메모리
85088SirCeness자동 인형 (IOI18_doll)C++14
2 / 100
51 ms10852 KiB
#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]; } //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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...