Submission #815792

# Submission time Handle Problem Language Result Execution time Memory
815792 2023-08-08T23:19:18 Z Lobo Mechanical Doll (IOI18_doll) C++17
100 / 100
53 ms 15444 KB
#include "doll.h"
#include<bits/stdc++.h>
using namespace std;
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define int long long

const int inf = 1e18+10;
const int maxn = 2e5+10;

int n, m;
vector<int> g[maxn];

void create_circuit(int32_t M, std::vector<int32_t> A) {
	n = A.size();
	m = M;
	vector<int32_t> c(m+1),x,y;
	vector<int> next;
	for(int i = -1; i < n; i++) {
		int u,v;
		if(i == -1) u = 0, v = A[0];
		else if(i == n-1) u = A[n-1], v = 0;
		else u = A[i], v = A[i+1];

		next.pb(v);
	}

	int cnt = 1;
	vector<int> liga;
	int mult = 1;
	while(next.size() > 1) {
		vector<int> newnext;

		for(int i = 0; i < next.size()/2; i++) {
			newnext.pb(cnt);
			x.pb(mult*next[i]);
			y.pb(mult*next[i+next.size()/2]);
			cnt++;
		}
		if(next.size()%2 == 1) {
			newnext.pb(cnt);
			y.pb(mult*next.back());
			x.pb(0);
			liga.pb(cnt);
			cnt++;
		}
		mult = -1;

		next = newnext;
	}

	for(auto v : liga) {
		x[v-1] = -next[0];
	}

	for(int i = 0; i <= m; i++) {
		c[i] = -next[0];
	}

	answer(c,x,y);
}

Compilation message

doll.cpp: In function 'void create_circuit(int32_t, std::vector<int>)':
doll.cpp:23:7: warning: variable 'u' set but not used [-Wunused-but-set-variable]
   23 |   int u,v;
      |       ^
doll.cpp:37:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |   for(int i = 0; i < next.size()/2; i++) {
      |                  ~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Correct 24 ms 9832 KB Output is correct
3 Correct 21 ms 9308 KB Output is correct
4 Correct 2 ms 4900 KB Output is correct
5 Correct 9 ms 6100 KB Output is correct
6 Correct 32 ms 10920 KB Output is correct
7 Correct 2 ms 4948 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Correct 24 ms 9832 KB Output is correct
3 Correct 21 ms 9308 KB Output is correct
4 Correct 2 ms 4900 KB Output is correct
5 Correct 9 ms 6100 KB Output is correct
6 Correct 32 ms 10920 KB Output is correct
7 Correct 2 ms 4948 KB Output is correct
8 Correct 36 ms 12568 KB Output is correct
9 Correct 38 ms 12636 KB Output is correct
10 Correct 53 ms 15444 KB Output is correct
11 Correct 2 ms 4948 KB Output is correct
12 Correct 3 ms 4948 KB Output is correct
13 Correct 2 ms 4948 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Correct 24 ms 9832 KB Output is correct
3 Correct 21 ms 9308 KB Output is correct
4 Correct 2 ms 4900 KB Output is correct
5 Correct 9 ms 6100 KB Output is correct
6 Correct 32 ms 10920 KB Output is correct
7 Correct 2 ms 4948 KB Output is correct
8 Correct 36 ms 12568 KB Output is correct
9 Correct 38 ms 12636 KB Output is correct
10 Correct 53 ms 15444 KB Output is correct
11 Correct 2 ms 4948 KB Output is correct
12 Correct 3 ms 4948 KB Output is correct
13 Correct 2 ms 4948 KB Output is correct
14 Correct 52 ms 14924 KB Output is correct
15 Correct 34 ms 12080 KB Output is correct
16 Correct 50 ms 14192 KB Output is correct
17 Correct 2 ms 4948 KB Output is correct
18 Correct 2 ms 4948 KB Output is correct
19 Correct 3 ms 4948 KB Output is correct
20 Correct 53 ms 15112 KB Output is correct
21 Correct 2 ms 4948 KB Output is correct
22 Correct 2 ms 4948 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Correct 2 ms 4948 KB Output is correct
3 Correct 2 ms 4948 KB Output is correct
4 Correct 2 ms 4948 KB Output is correct
5 Correct 2 ms 4948 KB Output is correct
6 Correct 2 ms 4948 KB Output is correct
7 Correct 2 ms 4948 KB Output is correct
8 Correct 2 ms 4948 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Correct 30 ms 11652 KB Output is correct
3 Correct 30 ms 11588 KB Output is correct
4 Correct 44 ms 13460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Correct 30 ms 11652 KB Output is correct
3 Correct 30 ms 11588 KB Output is correct
4 Correct 44 ms 13460 KB Output is correct
5 Correct 49 ms 14064 KB Output is correct
6 Correct 48 ms 13960 KB Output is correct
7 Correct 48 ms 14100 KB Output is correct
8 Correct 47 ms 13780 KB Output is correct
9 Correct 30 ms 11588 KB Output is correct
10 Correct 45 ms 13780 KB Output is correct
11 Correct 45 ms 13508 KB Output is correct
12 Correct 31 ms 11644 KB Output is correct
13 Correct 33 ms 11960 KB Output is correct
14 Correct 33 ms 12020 KB Output is correct
15 Correct 38 ms 12024 KB Output is correct
16 Correct 3 ms 5204 KB Output is correct
17 Correct 31 ms 11140 KB Output is correct
18 Correct 31 ms 11648 KB Output is correct
19 Correct 31 ms 11588 KB Output is correct
20 Correct 46 ms 13636 KB Output is correct
21 Correct 45 ms 13508 KB Output is correct
22 Correct 45 ms 13460 KB Output is correct