Submission #771550

# Submission time Handle Problem Language Result Execution time Memory
771550 2023-07-03T06:17:37 Z ttamx Mechanical Doll (IOI18_doll) C++14
6 / 100
70 ms 13472 KB
#include "doll.h"
#include<bits/stdc++.h>

using namespace std;

void create_circuit(int m,vector<int> a) {
	int n = a.size();
	vector<int> c(m+1);
	vector<int> lg(n+1);
	for(int i=2;i<=n;i++)lg[i]=lg[i/2]+1;
	c[0]=a[0];
	vector<int> x,y;
	auto add=[&](int u,int v){
		x.emplace_back(u);
		y.emplace_back(v);
		return -x.size();
	};
	vector<vector<int>> vec(m+1);
	a.emplace_back(0);
	for(int i=0;i<n;i++)vec[a[i]].emplace_back(a[i+1]);
	for(int i=1;i<=m;i++){
		int sz=vec[i].size();
		if(sz==0){
			c[i]=0;
			continue;
		}
		if(sz==1){
			c[i]=vec[i][0];
			continue;
		}
		int lv=lg[sz-1]+1;
		vector<int> res;
		int cnt=1<<(lv-1);
		int tar=-(x.size()+(1<<lv)-1);
		for(int k=1;k<=cnt;k++){
			int u=k-1;
			int v=k+cnt-1;
			res.emplace_back(add(u<sz?vec[i][u]:tar,v<sz?vec[i][v]:tar));
		}
		while(res.size()>1){
			vector<int> tmp;
			for(int i=0;i<res.size();i+=2)tmp.emplace_back(add(res[i],res[i+1]));
			res=tmp;
		}
		c[i]=res[0];
	}
	answer(c,x,y);
}

Compilation message

doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:42:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |    for(int i=0;i<res.size();i+=2)tmp.emplace_back(add(res[i],res[i+1]));
      |                ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 272 KB Output is correct
2 Correct 19 ms 6992 KB Output is correct
3 Correct 17 ms 5840 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 8 ms 3796 KB Output is correct
6 Correct 24 ms 8712 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 272 KB Output is correct
2 Correct 19 ms 6992 KB Output is correct
3 Correct 17 ms 5840 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 8 ms 3796 KB Output is correct
6 Correct 24 ms 8712 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 33 ms 8664 KB Output is correct
9 Correct 34 ms 10068 KB Output is correct
10 Correct 51 ms 13472 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 272 KB Output is correct
2 Correct 19 ms 6992 KB Output is correct
3 Correct 17 ms 5840 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 8 ms 3796 KB Output is correct
6 Correct 24 ms 8712 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 33 ms 8664 KB Output is correct
9 Correct 34 ms 10068 KB Output is correct
10 Correct 51 ms 13472 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Incorrect 70 ms 13220 KB state 'Y'
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB wrong motion
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB state 'Y'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB state 'Y'
2 Halted 0 ms 0 KB -