Submission #766076

# Submission time Handle Problem Language Result Execution time Memory
766076 2023-06-25T09:51:07 Z ono_de206 Mechanical Doll (IOI18_doll) C++14
6 / 100
66 ms 12308 KB
#include "doll.h"
#include<bits/stdc++.h>
using namespace std;

#define in insert
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second

// #define int long long
 
typedef long long ll;
typedef vector<int> vi;
typedef set<int> si;
typedef multiset<int> msi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

void create_circuit(int m, std::vector<int> a) {
	int n = a.size();
	a.pb(0);
	vector<int> C(m + 1, 0), X, Y;
	vector<vector<int>> nx(m + 1);
	nx[0].pb(a[0]);
	for(int i = 0; i < n; i++) {
		nx[a[i]].pb(a[i + 1]);
	}
	int now = 0, root;

	function<int(vector<int>&)> solve = [&](vector<int>& vec) {
		if(vec.size() == 2) {
			X.pb(vec[0]);
			Y.pb(vec[1]);
		} else {
			vector<int> first, second;
			for(int i = 0; i < (int)vec.size(); i += 2) {
				first.pb(vec[i]);
				second.pb(vec[i + 1]);
			}
			X.pb(solve(first));
			Y.pb(solve(second));
		}
		now++;
		return -now;
	};

	for(int i = 0; i <= m; i++) {
		if(nx[i].size() == 0) continue;
		if(nx[i].size() == 1) {
			C[i] = nx[i][0];
			continue;
		}
		int nxt = 1;
		while(nxt * 2 < nx[i].size()) nxt *= 2;
		reverse(all(nx[i]));
		while(nx[i].size() < nxt) nx[i].pb(i);
		reverse(all(nx[i]));
		C[i] = solve(nx[i]);
	}
	answer(C, X, Y);
}

Compilation message

doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:56:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |   while(nxt * 2 < nx[i].size()) nxt *= 2;
      |         ~~~~~~~~^~~~~~~~~~~~~~
doll.cpp:58:22: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   58 |   while(nx[i].size() < nxt) nx[i].pb(i);
      |         ~~~~~~~~~~~~~^~~~~
doll.cpp:30:15: warning: unused variable 'root' [-Wunused-variable]
   30 |  int now = 0, root;
      |               ^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 20 ms 6832 KB Output is correct
3 Correct 16 ms 5584 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 9 ms 3756 KB Output is correct
6 Correct 30 ms 8416 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 20 ms 6832 KB Output is correct
3 Correct 16 ms 5584 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 9 ms 3756 KB Output is correct
6 Correct 30 ms 8416 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 34 ms 8188 KB Output is correct
9 Correct 34 ms 9528 KB Output is correct
10 Correct 52 ms 12308 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 296 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 20 ms 6832 KB Output is correct
3 Correct 16 ms 5584 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 9 ms 3756 KB Output is correct
6 Correct 30 ms 8416 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 34 ms 8188 KB Output is correct
9 Correct 34 ms 9528 KB Output is correct
10 Correct 52 ms 12308 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 296 KB Output is correct
14 Incorrect 66 ms 11836 KB wrong motion
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB wrong motion
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB wrong motion
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB wrong motion
2 Halted 0 ms 0 KB -