Submission #429290

# Submission time Handle Problem Language Result Execution time Memory
429290 2021-06-15T20:04:18 Z peuch Mechanical Doll (IOI18_doll) C++17
70.6719 / 100
113 ms 12656 KB
#include "doll.h"
#include<bits/stdc++.h>
using namespace std;
 
int n;
int maxProf;
vector<int> X, Y;
 
int cnt = 0;
 
vector<pair<int, pair<int, int> > > aux;
 
int create();
int tree(int pai, int dir, int prof, int val, bool flag);
 
void create_circuit(int M, vector<int> A) {
	n = A.size();
	maxProf = log2(n + 1);
	if(__builtin_popcount(n + 1) != 1) maxProf++;
	vector<int> C (M + 1, -1);
	tree(0, 0, 0, 0, 1);
	sort(aux.begin(), aux.end());
	for(int i = 0; i < aux.size(); i++){
		if(aux[i].second.second) Y[aux[i].second.first] = A[i];
		else X[aux[i].second.first] = A[i];
	}
//	for(int i = 0; i < X.size(); i++){
//		printf("%d %d\n", -i - 1, X[i]);
//		printf("%d %d\n", -i - 1, Y[i]);
//	}
	answer(C, X, Y);
}
 
int create(){
	X.push_back(0);
	Y.push_back(0);
	return X.size() - 1;
}
 
int tree(int pai, int dir, int prof, int val, bool flag){
	if(cnt >= n && !flag) return -1;
	if(prof == maxProf){
		if(flag) return 0;
		cnt++;
		aux.push_back(make_pair(val, make_pair(pai, dir)));
		return -1;
	}
	int cur = create();
	int eVal = val, dVal = val + (1 << prof);
	int e = tree(cur, 0, prof + 1, eVal, 0);
	X[cur] = e;
	int d = tree(cur, 1, prof + 1, dVal, flag);
	Y[cur] = d;
	return -cur - 1;
}

Compilation message

doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:23:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |  for(int i = 0; i < aux.size(); i++){
      |                 ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 204 KB Output is partially correct
2 Correct 60 ms 7524 KB Output is correct
3 Partially correct 61 ms 7620 KB Output is partially correct
4 Partially correct 96 ms 11444 KB Output is partially correct
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 204 KB Output is partially correct
2 Correct 60 ms 7524 KB Output is correct
3 Partially correct 61 ms 7620 KB Output is partially correct
4 Partially correct 96 ms 11444 KB Output is partially correct
5 Partially correct 99 ms 12656 KB Output is partially correct
6 Partially correct 101 ms 12448 KB Output is partially correct
7 Partially correct 113 ms 12580 KB Output is partially correct
8 Partially correct 102 ms 12212 KB Output is partially correct
9 Partially correct 63 ms 7472 KB Output is partially correct
10 Partially correct 94 ms 12188 KB Output is partially correct
11 Partially correct 95 ms 11832 KB Output is partially correct
12 Partially correct 74 ms 7720 KB Output is partially correct
13 Correct 65 ms 8168 KB Output is correct
14 Partially correct 83 ms 8292 KB Output is partially correct
15 Partially correct 64 ms 8392 KB Output is partially correct
16 Partially correct 2 ms 520 KB Output is partially correct
17 Correct 70 ms 7816 KB Output is correct
18 Correct 62 ms 7656 KB Output is correct
19 Partially correct 67 ms 7724 KB Output is partially correct
20 Partially correct 99 ms 12048 KB Output is partially correct
21 Partially correct 105 ms 11804 KB Output is partially correct
22 Partially correct 102 ms 11816 KB Output is partially correct