QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#874692 | #8618. Have You Seen This Subarray? | Coffins# | WA | 2ms | 134912kb | C++20 | 3.0kb | 2025-01-28 13:44:04 | 2025-01-28 13:44:05 |
Judging History
answer
#pragma GCC optimize("O2")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#include<bits/stdc++.h>
using namespace std;
#define beg begin
#define All(A) A.beg(),A.end()
#define pb push_back
#define fst first
#define sec second
#define gr greater<>()
#define Lsh(A) sort(All(A)),\
A.erase(unique(All(A)),A.end());
#define u_set unordered_set
#define u_map unordered_map
#define lwb lower_bound
#define upb upper_bound
using ull=unsigned long long;
using ll=long long;
using ld=long double;
using pii=pair<int,int>;
using vi=vector<int>;
using gi=greater<int>;
using str=string;
using bqi=priority_queue<int>;
using lqi=priority_queue<int,vi,gi>;
using qi=queue<int>;
using si=set<int>;
using usi=u_set<int>;
using vll=vector<ll>;
using pll=pair<ll,ll>;
using vvi=vector<vi>;
using vvl=vector<vll>;
using vpi=vector<pii>;
int n,m,q;
namespace sub1{
const int N=201;
const int M=1e5+1;
using bst=bitset<M>;
bst bs[N][N];int a[N];
void upd(int c)
{
for(int i=1;i<n;i++)
bs[a[i]][a[i+1]][c]=1;
}
void solve()
{
for(int i=1;i<=n;i++)a[i]=i;upd(0);
for(int i=1;i<=m;i++)
{
int x,y;cin>>x>>y;
swap(a[x],a[y]),upd(i);
}for(int i=1;i<=q;i++)
{
int k;cin>>k;bst rs;rs=~rs;
for(int i=1;i<=k;i++)cin>>a[i];
for(int i=1;i<k;i++)
rs&=bs[a[i]][a[i+1]];
cout<<rs._Find_first()<<'\n';
}
}
}
namespace sub2{
const int N=1e5+5;
int a[N],x[N],y[N],k[N];
vi qr[N];u_map<int,u_map<int,vi> > vec;
u_map<int,int> ps[N];
int rs[N],vl[N];
void del(int x,int v,int o)
{
if(x>1&&a[x-1]>0)
{
for(int id:vec[a[x-1]][v])
vl[id]--;
}if(x<n&&a[x+1]>0)
{
for(int id:vec[v][a[x+1]])
vl[id]--;
}a[x]=-1;
}
void ins(int x,int v,int o)
{
if(x>1&&a[x-1]>0)
{
vi nv;
for(int id:vec[a[x-1]][v])
{
vl[id]++;if(vl[id]==k[id]-1)
rs[id]=o;else nv.pb(id);
}vec[a[x-1]][v]=nv;
}if(x<n&&a[x+1]>0)
{
vi nv;
for(int id:vec[v][a[x+1]])
{
vl[id]++;if(vl[id]==k[id]-1)
rs[id]=o;else nv.pb(id);
}vec[v][a[x+1]]=nv;
}a[x]=v;
}
void solve()
{
for(int i=1;i<=m;i++)cin>>x[i]>>y[i];
for(int i=1;i<=q;i++)
{
cin>>k[i];qr[i].resize(k[i]);
for(int j=0;j<k[i];j++)
cin>>qr[i][j],ps[i][qr[i][j]]=j;
for(int j=0;j+1<k[i];j++)
vec[qr[i][j]][qr[i][j+1]].pb(i);
}for(int i=1;i<=n;i++)a[i]=-1;
for(int i=1;i<=n;i++)ins(i,i,0);
for(int i=1;i<=m;i++)
{
int x=sub2::x[i],y=sub2::y[i];
int vx=a[x],vy=a[y];
del(x,vx,i),del(y,vy,i);
ins(x,vy,i),ins(y,vx,i);
}for(int i=1;i<=q;i++)
cout<<rs[i]<<'\n';
}
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
cin>>n>>m>>q;
if(n<=200)sub1::solve();
else sub2::solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 24580kb
input:
6 3 5 1 5 3 4 1 6 2 4 1 3 3 1 5 3 3 4 5 4 5 2 4 3 2 6 2
output:
1 3 0 2 3
result:
ok 5 number(s): "1 3 0 2 3"
Test #2:
score: 0
Accepted
time: 2ms
memory: 134912kb
input:
50 50 16 21 30 14 39 5 32 31 48 38 50 40 49 14 33 32 42 7 15 5 25 24 28 8 10 18 24 5 39 4 37 9 28 29 39 2 35 11 32 48 49 12 17 38 44 26 33 12 40 19 49 40 41 17 18 20 30 11 15 21 36 37 38 7 48 17 21 8 38 30 34 3 31 7 12 31 47 2 37 20 41 13 40 33 39 10 49 19 40 12 30 23 28 9 45 27 32 4 37 27 29 2 44 4...
output:
0 29 44 22 23 18 1 37 3 16 0 16 0 13 0 0
result:
ok 16 numbers
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 12264kb
input:
500 500 165 5 424 246 385 355 428 43 338 214 378 286 469 6 467 149 333 203 411 7 111 395 483 256 288 69 414 33 429 159 425 22 470 13 425 235 292 291 412 76 224 64 207 198 365 268 314 116 366 338 386 58 265 328 330 146 493 89 288 120 465 187 201 336 499 406 485 195 406 56 485 410 424 125 149 154 216 ...
output:
68 77 385 0 391 119 0 443 216 0 0 420 0 136 434 0 163 77 410 122 0 0 436 474 285 0 109 89 13 0 38 0 0 133 48 390 0 0 157 25 402 0 232 272 0 0 374 294 226 0 16 0 151 295 80 17 184 379 333 199 431 0 0 0 10 0 0 0 357 431 165 0 0 408 296 0 0 0 191 0 275 233 184 284 0 107 0 213 193 317 0 0 349 311 82 0 1...
result:
wrong answer 119th numbers differ - expected: '106', found: '280'