QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#828500 | #9914. 前往何方 | zhenjianuo2025 | 0 | 360ms | 5768kb | C++20 | 2.4kb | 2024-12-23 17:15:21 | 2024-12-23 17:15:21 |
Judging History
answer
#include<bits/stdc++.h>
#include "wheretoreach.h"
using namespace std;
#define vec vector
#define pb push_back
#define eb emplace_back
#define siz(vec) ((int)(vec).size())
#define all(vec) (vec).begin(),(vec).end()
template<class T>
void operator +=(vec<T> &a,T b){a.push_back(b);}
template<class T>
void operator --(vec<T> &a){a.pop_back();}
#define pii pair<int,int>
#define x first
#define y second
#define mp make_pair
#define exc(exp) if(exp)continue;
#define stop(exp) if(exp)break;
#define ret(exp) if(exp)return;
#define deb(var) cerr<<#var<<'='<<(var)<<"; "
#define debl(var) cerr<<#var<<'='<<(var)<<";\n"
#define ins insert
#define era erase
#define lb lower_bound
#define inf (long long)(1e9)
template<class T>
bool Min(T &x,T y){return x>y?x=y,1:0;}
template<class T>
bool Max(T &x,T y){return x<y?x=y,1:0;}
int add(int x);
int remove(int x);
void report(int x,int y);
mt19937 eng(random_device{}());
int n,vis[10010],tmp[10010],ins[10010],ord[10010];
void sol(int l,int r,vec<int> w){
ret(l>r);
int mid=(l+r)>>1;
vec<int> v;
if(l==1&&r==n){
v=w;
}else{
for(auto x:w)tmp[x]=0;
// fill(vis+l,vis+r+1,0);
iota(ord+l,ord+r+1,l);
for(int T=1;T<=2;T++){
shuffle(ord+l,ord+r+1,eng);
int cnt=0;
for(int j=l;j<=r;j++){
int i=ord[j];
// exc(vis[i]);
if((cnt=add(i))>2){
cnt=remove(i);
}else{
ins[i]=1;
// vis[i]=1;
}
}
for(auto x:w){
exc(tmp[x]);
if(x<=l){
}else if(x<=r){
tmp[x]=1;
}else{
if(add(x)>cnt)tmp[x]=1;
assert(remove(x)==cnt);
}
}
for(int i=l;i<=r;i++){
if(ins[i]){
remove(i);
ins[i]=0;
}
}
// if(!count(vis+l,vis+r+1,0))break;
}
for(auto x:w){
if(tmp[x])v+=x;
}
}
w=v;
if(l==r){
for(auto x:w){
report(l,x);
}
}else{
sol(l,mid,w);
sol(mid+1,r,w);
}
}
void solve(int N){
n=N;
vec<int> v(n-1);
iota(all(v),2);
sol(1,n,v);
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 8ms
memory: 3948kb
input:
500 310 77 468 235 218 93 58 406 223 334 159 243 204 48 144 107 492 288 447 165 102 407 340 299 450 126 140 234 209 62 111 204 453 306 4 476 126 358 183 317 360 489 149 158 232 22 326 372 92 383 410 24 199 14 401 480 69 329 192 167 409 152 426 354 435 60 146 404 334 187 208 305 123 55 30 79 469 72 2...
output:
-1 1
result:
wrong answer Wrong Answer (or #queries exceeded).
Subtask #2:
score: 0
Wrong Answer
Test #9:
score: 0
Wrong Answer
time: 59ms
memory: 4672kb
input:
2500 887 818 1296 878 1605 2107 803 2410 1919 1135 860 1160 1364 2414 1375 500 894 2173 2322 2449 211 1732 1821 573 413 1556 1574 1977 709 162 2002 1577 1626 1895 1563 688 2151 2293 661 69 317 1170 2335 1549 1481 1349 1500 779 1593 735 1824 2380 639 2334 1496 2335 1956 1384 2476 1583 1035 163 720 70...
output:
-1 2
result:
wrong answer Wrong Answer (or #queries exceeded).
Subtask #3:
score: 0
Wrong Answer
Test #17:
score: 0
Wrong Answer
time: 360ms
memory: 5768kb
input:
10000 6139 8917 131 5800 5366 5247 1298 5035 3966 3518 4889 7202 6547 1919 5829 9494 8012 6029 3868 6403 1909 8116 5734 6122 2683 4779 9275 6673 7433 9042 7646 2032 3547 6306 1943 8382 4061 6428 8240 3548 460 2795 3451 4320 5904 6627 8709 7621 8706 3534 748 4873 8101 4261 5359 3304 6254 4687 6492 53...
output:
-1 3
result:
wrong answer Wrong Answer (or #queries exceeded).