#include"bits/stdc++.h"
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class x>
using ordered_set = tree<x, null_type,less<x>, rb_tree_tag,tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//long long a[2000005],up[2000005];
#include "xylophone.h"
static int A[5000];
long long plc[5005],a[5005];
void solve(int N) {
for(int i=2;i<=N;i++)
{
long long chek = query(i,N);
if(chek!=N-1)
{
plc[1]=i-1;
a[i-1]=1;
break;
}
}
long long bef=0;
for(int i=plc[1]+1;i<=N;i++)
{
long long chek = query(plc[1],i);
if(chek!=bef)
{
answer(i,chek+1);
a[i]=chek+1;
plc[chek+1]=i;
}
else
{
long long an = query(plc[chek+1],i);
if(plc[(chek+1)-an]==0)
{
a[i]=(chek+1)-an;
plc[(chek+1)-an]=i;
}
else
{
long long an2 = query(plc[(chek+1)-an],i);
a[i]=((chek+1)-an) + an2;
plc[((chek+1)-an) + an2]=i;
}
}
bef=chek;
}
bef=0;
for(int i=plc[1]-1;i>0;i--)
{
long long chek = query(i,plc[1]);
if(chek!=bef)
{
answer(i,chek+1);
a[i]=chek+1;
plc[chek+1]=i;
}
else
{
long long an = query(i,plc[chek+1]);
if(plc[(chek+1)-an]==0)
{
a[i]=(chek+1)-an;
plc[(chek+1)-an]=i;
answer(i,(chek+1)-an);
}
else
{
long long an2 = query(i,plc[(chek+1)-an]);
a[i]=((chek+1)-an) + an2;
plc[((chek+1)-an) + an2]=i;
answer(i,((chek+1)-an) + an2);
}
}
bef=chek;
}
}
Compilation message
xylophone.cpp:13:12: warning: 'A' defined but not used [-Wunused-variable]
13 | static int A[5000];
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
208 KB |
Wrong Answer [6] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
208 KB |
Wrong Answer [6] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
208 KB |
Wrong Answer [6] |
2 |
Halted |
0 ms |
0 KB |
- |