Submission #986401

# Submission time Handle Problem Language Result Execution time Memory
986401 2024-05-20T12:50:32 Z Pyqe Mechanical Doll (IOI18_doll) C++17
100 / 100
116 ms 53548 KB
#include "doll.h"
#include <bits/stdc++.h>

using namespace std;

long long n,nn,mm,xy[200069][2],am[20][262169];
vector<int> v,vv[2];
bitset<200069> vtd;

void create_circuit(int m,vector<int> a)
{
	long long i,j,ii,p,k,l,c;
	
	a.push_back(0);
	n=a.size();
	for(i=0;i<m+1;i++)
	{
		v.push_back(-1);
	}
	for(nn=1;nn<n;nn*=2);
	mm=nn-1;
	for(k=(nn-n)/2;k>0;mm-=k,k/=2);
	c=mm;
	for(i=0;i<nn;i++)
	{
		if(i<nn-n)
		{
			am[0][i]=1;
		}
		else
		{
			am[0][i]=0;
		}
	}
	for(i=1;1<<i<=nn;i++)
	{
		for(j=0;j<nn;j+=1<<i)
		{
			if(am[i-1][j+(1<<i-1)]==1)
			{
				am[i][j]=1;
			}
			else
			{
				am[i][j]=c;
				for(ii=0;ii<2;ii++)
				{
					xy[c][ii]=-am[i-1][j+ii*(1<<i-1)];
				}
				c--;
			}
		}
	}
	for(i=0;i<n;i++)
	{
		for(p=1;1;)
		{
			k=-xy[p][vtd[p]];
			vtd[p]=!vtd[p];
			if(k==0)
			{
				xy[p][!vtd[p]]=a[i];
				break;
			}
			p=k;
		}
	}
	for(i=1;i<=mm;i++)
	{
		for(ii=0;ii<2;ii++)
		{
			vv[ii].push_back(xy[i][ii]);
		}
	}
	answer(v,vv[0],vv[1]);
}

Compilation message

doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:39:22: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   39 |    if(am[i-1][j+(1<<i-1)]==1)
      |                     ~^~
doll.cpp:48:35: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   48 |      xy[c][ii]=-am[i-1][j+ii*(1<<i-1)];
      |                                  ~^~
doll.cpp:12:23: warning: unused variable 'l' [-Wunused-variable]
   12 |  long long i,j,ii,p,k,l,c;
      |                       ^
# Verdict Execution time Memory Grader output
1 Correct 2 ms 10588 KB Output is correct
2 Correct 36 ms 39848 KB Output is correct
3 Correct 40 ms 43728 KB Output is correct
4 Correct 2 ms 12632 KB Output is correct
5 Correct 9 ms 14036 KB Output is correct
6 Correct 50 ms 45872 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 10588 KB Output is correct
2 Correct 36 ms 39848 KB Output is correct
3 Correct 40 ms 43728 KB Output is correct
4 Correct 2 ms 12632 KB Output is correct
5 Correct 9 ms 14036 KB Output is correct
6 Correct 50 ms 45872 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 64 ms 49028 KB Output is correct
9 Correct 78 ms 37580 KB Output is correct
10 Correct 97 ms 43772 KB Output is correct
11 Correct 3 ms 12636 KB Output is correct
12 Correct 2 ms 12636 KB Output is correct
13 Correct 2 ms 6744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 10588 KB Output is correct
2 Correct 36 ms 39848 KB Output is correct
3 Correct 40 ms 43728 KB Output is correct
4 Correct 2 ms 12632 KB Output is correct
5 Correct 9 ms 14036 KB Output is correct
6 Correct 50 ms 45872 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 64 ms 49028 KB Output is correct
9 Correct 78 ms 37580 KB Output is correct
10 Correct 97 ms 43772 KB Output is correct
11 Correct 3 ms 12636 KB Output is correct
12 Correct 2 ms 12636 KB Output is correct
13 Correct 2 ms 6744 KB Output is correct
14 Correct 116 ms 47200 KB Output is correct
15 Correct 60 ms 48864 KB Output is correct
16 Correct 99 ms 51176 KB Output is correct
17 Correct 2 ms 12632 KB Output is correct
18 Correct 2 ms 12632 KB Output is correct
19 Correct 2 ms 12636 KB Output is correct
20 Correct 99 ms 53548 KB Output is correct
21 Correct 1 ms 6492 KB Output is correct
22 Correct 2 ms 8540 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 12632 KB Output is correct
2 Correct 2 ms 12636 KB Output is correct
3 Correct 2 ms 12636 KB Output is correct
4 Correct 2 ms 12632 KB Output is correct
5 Correct 2 ms 12636 KB Output is correct
6 Correct 2 ms 12636 KB Output is correct
7 Correct 2 ms 12636 KB Output is correct
8 Correct 2 ms 12632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 14684 KB Output is correct
2 Correct 55 ms 47176 KB Output is correct
3 Correct 68 ms 47280 KB Output is correct
4 Correct 95 ms 51256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 14684 KB Output is correct
2 Correct 55 ms 47176 KB Output is correct
3 Correct 68 ms 47280 KB Output is correct
4 Correct 95 ms 51256 KB Output is correct
5 Correct 84 ms 53008 KB Output is correct
6 Correct 94 ms 52484 KB Output is correct
7 Correct 88 ms 52492 KB Output is correct
8 Correct 93 ms 52372 KB Output is correct
9 Correct 67 ms 47228 KB Output is correct
10 Correct 90 ms 51988 KB Output is correct
11 Correct 93 ms 51596 KB Output is correct
12 Correct 57 ms 47488 KB Output is correct
13 Correct 64 ms 48460 KB Output is correct
14 Correct 59 ms 48148 KB Output is correct
15 Correct 72 ms 48260 KB Output is correct
16 Correct 5 ms 29272 KB Output is correct
17 Correct 53 ms 45896 KB Output is correct
18 Correct 57 ms 47492 KB Output is correct
19 Correct 56 ms 47456 KB Output is correct
20 Correct 90 ms 52144 KB Output is correct
21 Correct 87 ms 51748 KB Output is correct
22 Correct 92 ms 51748 KB Output is correct