#include "library.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAXN = 1000;
int N;
int memo[MAXN+10][MAXN+10];
vector<int> adj[MAXN+10];
bool vis[MAXN+10];
vector<int> ans;
int query(int l, int r)
{
int i, j;
if(l==r) memo[l][r]=1;
else if(memo[l][r]==-1)
{
vector<int> t;
t.resize(N);
for(i=l; i<=r; i++) t[i-1]=1;
memo[l][r]=Query(t);
}
return memo[l][r];
}
void Solve(int _N)
{
int i, j;
N=_N;
memset(memo, -1, sizeof(memo));
for(i=1; i<=N; i++)
{
int lo, hi;
lo=0, hi=i;
while(lo+1<hi)
{
int mid=lo+hi>>1, t;
if(mid==0) t=2;
else t=query(mid, i-1)+1-query(mid, i);
if(t<=0) hi=mid;
else lo=mid;
}
if(lo) adj[i].push_back(lo), adj[lo].push_back(i);
lo=0, hi=i;
while(lo+1<hi)
{
int mid=lo+hi>>1, t;
if(mid==0) t=2;
else t=query(mid, i-1)+1-query(mid, i);
if(t<=1) hi=mid;
else lo=mid;
}
if(lo) adj[i].push_back(lo), adj[lo].push_back(i);
}
int now=0;
for(i=1; i<=N; i++) if(adj[i].size()==1) break;
now=i;
while(1)
{
ans.push_back(now); vis[now]=1;
int cnt=0;
for(int nxt : adj[now])
{
if(vis[nxt]) continue;
now=nxt; cnt++;
}
if(!cnt) break;
}
Answer(ans);
}
Compilation message
library.cpp: In function 'int query(int, int)':
library.cpp:20:12: warning: unused variable 'j' [-Wunused-variable]
int i, j;
^
library.cpp: In function 'void Solve(int)':
library.cpp:46:23: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
int mid=lo+hi>>1, t;
~~^~~
library.cpp:58:23: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
int mid=lo+hi>>1, t;
~~^~~
library.cpp:35:12: warning: unused variable 'j' [-Wunused-variable]
int i, j;
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
57 ms |
4216 KB |
# of queries: 2827 |
2 |
Correct |
55 ms |
4344 KB |
# of queries: 2917 |
3 |
Correct |
57 ms |
4264 KB |
# of queries: 2997 |
4 |
Correct |
40 ms |
4332 KB |
# of queries: 3035 |
5 |
Correct |
57 ms |
4216 KB |
# of queries: 3023 |
6 |
Correct |
62 ms |
4344 KB |
# of queries: 2996 |
7 |
Correct |
57 ms |
4344 KB |
# of queries: 3048 |
8 |
Correct |
40 ms |
4332 KB |
# of queries: 2910 |
9 |
Correct |
50 ms |
4332 KB |
# of queries: 2959 |
10 |
Correct |
31 ms |
4216 KB |
# of queries: 1710 |
11 |
Incorrect |
5 ms |
4216 KB |
Wrong Answer [5] |
12 |
Correct |
5 ms |
4344 KB |
# of queries: 1 |
13 |
Correct |
5 ms |
4216 KB |
# of queries: 3 |
14 |
Correct |
5 ms |
4344 KB |
# of queries: 6 |
15 |
Correct |
6 ms |
4472 KB |
# of queries: 73 |
16 |
Correct |
8 ms |
4344 KB |
# of queries: 191 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
57 ms |
4216 KB |
# of queries: 2827 |
2 |
Correct |
55 ms |
4344 KB |
# of queries: 2917 |
3 |
Correct |
57 ms |
4264 KB |
# of queries: 2997 |
4 |
Correct |
40 ms |
4332 KB |
# of queries: 3035 |
5 |
Correct |
57 ms |
4216 KB |
# of queries: 3023 |
6 |
Correct |
62 ms |
4344 KB |
# of queries: 2996 |
7 |
Correct |
57 ms |
4344 KB |
# of queries: 3048 |
8 |
Correct |
40 ms |
4332 KB |
# of queries: 2910 |
9 |
Correct |
50 ms |
4332 KB |
# of queries: 2959 |
10 |
Correct |
31 ms |
4216 KB |
# of queries: 1710 |
11 |
Incorrect |
5 ms |
4216 KB |
Wrong Answer [5] |
12 |
Correct |
5 ms |
4344 KB |
# of queries: 1 |
13 |
Correct |
5 ms |
4216 KB |
# of queries: 3 |
14 |
Correct |
5 ms |
4344 KB |
# of queries: 6 |
15 |
Correct |
6 ms |
4472 KB |
# of queries: 73 |
16 |
Correct |
8 ms |
4344 KB |
# of queries: 191 |
17 |
Incorrect |
619 ms |
4728 KB |
Wrong Answer [3] |
18 |
Incorrect |
570 ms |
4420 KB |
Wrong Answer [3] |
19 |
Incorrect |
635 ms |
4484 KB |
Wrong Answer [3] |
20 |
Incorrect |
578 ms |
4484 KB |
Wrong Answer [3] |
21 |
Correct |
478 ms |
4472 KB |
# of queries: 18847 |
22 |
Incorrect |
598 ms |
4368 KB |
Wrong Answer [3] |
23 |
Incorrect |
599 ms |
4468 KB |
Wrong Answer [3] |
24 |
Correct |
216 ms |
4348 KB |
# of queries: 9697 |
25 |
Incorrect |
599 ms |
4472 KB |
Wrong Answer [3] |
26 |
Correct |
535 ms |
4464 KB |
# of queries: 19657 |
27 |
Correct |
199 ms |
4332 KB |
# of queries: 9640 |
28 |
Incorrect |
600 ms |
4476 KB |
Wrong Answer [3] |
29 |
Incorrect |
567 ms |
4464 KB |
Wrong Answer [3] |
30 |
Incorrect |
633 ms |
4484 KB |
Wrong Answer [3] |