Submission #716887

# Submission time Handle Problem Language Result Execution time Memory
716887 2023-03-31T10:12:11 Z myrcella Mechanical Doll (IOI18_doll) C++17
0 / 100
49 ms 5164 KB
//by szh
#include<bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pb push_back
#define debug(x) cerr<<#x<<"="<<x<<endl
#define pq priority_queue
#define inf 0x3f
#define rep(i,a,b) for (int i=a;i<(b);i++)
#define MP make_pair
#define SZ(x) (int(x.size()))
#define ll long long
#define mod 1000000007
#define ALL(x) x.begin(),x.end()
void inc(int &a,int b) {a=(a+b)%mod;}
void dec(int &a,int b) {a=(a-b+mod)%mod;}
int lowbit(int x) {return x&(-x);}
ll p0w(ll base,ll p) {ll ret=1;while(p>0){if (p%2ll==1ll) ret=ret*base%mod;base=base*base%mod;p/=2ll;}return ret;}

#include "doll.h"

const int maxn = 2e5+10;

vector <int> X,Y;
int tot;
int cur = 1;
int cnt = 0;

void dfs(int suf,int lg) {
	int id = cur++;
	X.pb(-maxn),Y.pb(-maxn);
	lg--;
	if (lg==0) {
		if (suf+1==tot) X[id-1] = -1;
		return;
	}
	Y[id-1] = -cur;
	dfs(suf,lg);
	if (suf + (1<<lg) < tot) {
		X[id-1] = -cur;
		dfs(suf + (1<<lg), lg);
	}
	else X[id-1] = -1;
}

bool vis[maxn];

int nxt(int x) {
	int ret;
	if (vis[x]==false) ret = X[x-1];
	else ret = Y[x-1];
	vis[x]^=1;
	if (vis[x]) cnt++;
	else cnt--;
	return -ret;
}

void create_circuit(int M, std::vector<int> A) {
	tot=M+1;
  A.pb(0);
  int lg = 0;
  while ((1<<lg)<M+1) lg++;
  dfs(0,lg);
  memset(vis,0,sizeof(vis));
  rep(i,0,tot) {
	  int cur=1,tmp;
	  while ((tmp=nxt(cur))!=maxn) 
		  cur = tmp;
		if (vis[cur]==false) Y[cur-1] = A[i];
		else X[cur-1] = A[i];
  }
  vector <int> C;
  rep(i,0,tot) C.pb(-1);
  answer(C, X, Y);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Incorrect 49 ms 5164 KB state 'Y'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Incorrect 49 ms 5164 KB state 'Y'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Incorrect 49 ms 5164 KB state 'Y'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 468 KB wrong motion
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 468 KB wrong motion
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 468 KB wrong motion
2 Halted 0 ms 0 KB -