Submission #376968

# Submission time Handle Problem Language Result Execution time Memory
376968 2021-03-12T13:25:28 Z i_am_noob Library (JOI18_library) C++17
0 / 100
28 ms 512 KB
#include<bits/stdc++.h>
#include "library.h"
using namespace std;

#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define inf 1010000000
//#define inf 4000000000000000000
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#ifdef i_am_noob
#define bug(...) cerr << "#" << __LINE__ << ' ' << #__VA_ARGS__ << "- ", _do(__VA_ARGS__)
template<typename T> void _do(T && x) {static int cnt=0;cerr << x << endl;cnt++;if(cnt>1000) exit(0);}
template<typename T, typename ...S> void _do(T && x, S&&...y) {cerr << x << ", "; _do(y...);}
#else
#define bug(...) 826
#endif

const int maxn=1005;
vector<int> adj[maxn],res;

void dfs(int u, int par){
	res.pb(u+1);
	for(auto v: adj[u]) if(v!=par) dfs(v,u);
}

void Solve(int n){
	vector<int> tmp;
	int val[maxn],l,r,mid,x;
	val[0]=1;
	rep2(i,1,n){
		tmp.clear();
		rep1(j,i+1) tmp.pb(1);
		rep2(j,i+1,n) tmp.pb(0);
		val[i]=Query(tmp);
		if(val[i]==val[i-1]+1) continue;
		if(val[i]==val[i-1]){
			l=0,r=i-1;
			while(l<r){
				mid=l+r>>1;
				tmp=vector<int>(n,0);
				rep1(j,mid+1) tmp[j]=1;
				tmp[i]=1;
				if(Query(tmp)==val[mid]) r=mid;
				else l=mid+1;
			}
			adj[l].pb(i),adj[i].pb(l);
			continue;
		}
		l=0,r=i-1;
		while(l<r){
			mid=l+r>>1;
			tmp=vector<int>(n,0);
			rep1(j,mid+1) tmp[j]=1;
			tmp[i]=1;
			if(Query(tmp)<=val[mid]) r=mid;
			else l=mid+1;
		}
		x=l;
		adj[x].pb(i),adj[i].pb(x);
		l=x+1,r=i-1;
		while(l<r){
			mid=l+r>>1;
			tmp=vector<int>(n,0);
			rep1(j,mid+1) tmp[j]=1;
			tmp[i]=1;
			if(Query(tmp)<val[mid]) r=mid;
			else l=mid+1;
		}
		adj[l].pb(i),adj[i].pb(l);
	}
	rep(n) if(sz(adj[i])==1){
		dfs(i,-1);
		Answer(res);
		break;
	}
}

Compilation message

library.cpp: In function 'void Solve(int)':
library.cpp:50:10: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   50 |     mid=l+r>>1;
      |         ~^~
library.cpp:62:9: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   62 |    mid=l+r>>1;
      |        ~^~
library.cpp:73:9: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   73 |    mid=l+r>>1;
      |        ~^~
# Verdict Execution time Memory Grader output
1 Correct 23 ms 384 KB # of queries: 1464
2 Correct 23 ms 364 KB # of queries: 1471
3 Correct 16 ms 404 KB # of queries: 1534
4 Correct 28 ms 364 KB # of queries: 1542
5 Correct 26 ms 364 KB # of queries: 1529
6 Correct 23 ms 364 KB # of queries: 1533
7 Correct 23 ms 364 KB # of queries: 1542
8 Correct 23 ms 364 KB # of queries: 1457
9 Correct 17 ms 512 KB # of queries: 1547
10 Correct 16 ms 364 KB # of queries: 903
11 Incorrect 1 ms 364 KB Wrong Answer [7]
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 23 ms 384 KB # of queries: 1464
2 Correct 23 ms 364 KB # of queries: 1471
3 Correct 16 ms 404 KB # of queries: 1534
4 Correct 28 ms 364 KB # of queries: 1542
5 Correct 26 ms 364 KB # of queries: 1529
6 Correct 23 ms 364 KB # of queries: 1533
7 Correct 23 ms 364 KB # of queries: 1542
8 Correct 23 ms 364 KB # of queries: 1457
9 Correct 17 ms 512 KB # of queries: 1547
10 Correct 16 ms 364 KB # of queries: 903
11 Incorrect 1 ms 364 KB Wrong Answer [7]
12 Halted 0 ms 0 KB -