QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#718175 | #2743. Seats | XY_Eleven | 0 ✓ | 0ms | 0kb | C++20 | 5.4kb | 2024-11-06 19:53:33 | 2024-11-06 19:53:34 |
Judging History
answer
#include <bits/stdc++.h>
#include "seats.h"
// #include <windows.h>
// #include <bits/extc++.h>
// using namespace __gnu_pbds;
using namespace std;
//#pragma GCC optimize(3)
#define DB double
#define LL long long
#define ULL unsigned long long
#define in128 __int128
#define cint const int
#define cLL const LL
#define For(z,e1,e2) for(int z=(e1);z<=(e2);z++)
#define Rof(z,e1,e2) for(int z=(e2);z>=(e1);z--)
#define For_(z,e1,e2) for(int z=(e1);z<(e2);z++)
#define Rof_(z,e1,e2) for(int z=(e2);z>(e1);z--)
#define inint(e) scanf("%d",&e)
#define inll(e) scanf("%lld",&e)
#define inpr(e1,e2) scanf("%d%d",&e1,&e2)
#define in3(e1,e2,e3) scanf("%d%d%d",&e1,&e2,&e3)
#define outint(e) printf("%d\n",e)
#define outint_(e) printf("%d%c",e," \n"[i==n])
#define outint2_(e,e1,e2) printf("%d%c",e," \n"[(e1)==(e2)])
#define outll(e) printf("%lld\n",e)
#define outll_(e) printf("%lld%c",e," \n"[i==n])
#define outll2_(e,e1,e2) printf("%lld%c",e," \n"[(e1)==(e2)])
#define exc(e) if(e) continue
#define stop(e) if(e) break
#define ret(e) if(e) return
#define ll(e) (1ll*(e))
#define pb push_back
#define ft first
#define sc second
#define pii pair<int,int>
#define pli pair<long long,int>
#define vct vector
#define clean(e) while(!e.empty()) e.pop()
#define all(ev) ev.begin(),ev.end()
#define sz(ev) ((int)ev.size())
#define debug(x) printf("%s=%d\n",#x,x)
#define x0 __xx00__
#define y1 __yy11__
#define ffo fflush(stdout)
// cLL mod=998244353,G=404;
cLL mod=1686688681ll;
// cLL mod[2]={1686688681ll,1666888681ll},base[2]={166686661ll,188868881ll};
template <typename Type> void get_min(Type &w1,const Type w2) { if(w2<w1) w1=w2; } template <typename Type> void get_max(Type &w1,const Type w2) { if(w2>w1) w1=w2; }
template <typename Type> Type up_div(Type w1,Type w2) { return (w1/w2+(w1%w2?1:0)); }
template <typename Type> Type gcd(Type X_,Type Y_) { Type R_=X_%Y_; while(R_) { X_=Y_; Y_=R_; R_=X_%Y_; } return Y_; } template <typename Type> Type lcm(Type X_,Type Y_) { return (X_/gcd(X_,Y_)*Y_); }
template <typename Type> Type md(Type w1,const Type w2=mod) { w1%=w2; if(w1<0) w1+=w2; return w1; } template <typename Type> Type md_(Type w1,const Type w2=mod) { w1%=w2; if(w1<=0) w1+=w2; return w1; }
void ex_gcd(LL &X_,LL &Y_,LL A_,LL B_) { if(!B_) { X_=1ll; Y_=0ll; return ; } ex_gcd(Y_,X_,B_,A_%B_); X_=md(X_,B_); Y_=(1ll-X_*A_)/B_; } LL inv(LL A_,LL B_=mod) { LL X_=0ll,Y_=0ll; ex_gcd(X_,Y_,A_,B_); return X_; }
template <typename Type> void add(Type &w1,const Type w2,const Type M_=mod) { w1=md(w1+w2,M_); } void mul(LL &w1,cLL w2,cLL M_=mod) { w1=md(w1*md(w2,M_),M_); } template <typename Type> Type pw(Type X_,Type Y_,Type M_=mod) { Type S_=1; while(Y_) { if(Y_&1) mul(S_,X_,M_); Y_>>=1; mul(X_,X_,M_); } return S_; }
template <typename Type> Type bk(vector <Type> &V_) { auto T_=V_.back(); V_.pop_back(); return T_; } template <typename Type> Type tp(stack <Type> &V_) { auto T_=V_.top(); V_.pop(); return T_; } template <typename Type> Type frt(queue <Type> &V_) { auto T_=V_.front(); V_.pop(); return T_; }
template <typename Type> Type bg(set <Type> &V_) { auto T_=*V_.begin(); V_.erase(V_.begin()); return T_; } template <typename Type> Type bk(set <Type> &V_) { auto T_=*prev(V_.end()); V_.erase(*prev(V_.end())); return T_; }
mt19937 gen(time(NULL)); int rd() { return abs((int)gen()); }
int rnd(int l,int r) { return rd()%(r-l+1)+l; }
void main_init()
{
}
cint N=1.02e6;
int d1,d2,n;
struct Node
{
int l,r,mid;
int mn,tag,cnt;
};
struct SegTree
{
Node t[N<<2];
void bld(int p,int l,int r)
{
int mid=l+r>>1;
t[p]={l,r,mid,0,0,r-l+1};
ret(l>=r);
bld(p<<1,l,mid),bld(p<<1|1,mid+1,r);
}
void setf(int p,int w)
{
t[p].mn+=w,t[p].tag+=w;
}
void pdn(int p)
{
ret(!t[p].tag);
setf(p<<1,t[p].tag),setf(p<<1|1,t[p].tag);
t[p].tag=0;
}
void pup(int p)
{
t[p].mn=min(t[p<<1].mn,t[p<<1|1].mn),t[p].cnt=0;
For(k,0,1) if(t[p].mn==t[p<<1|k].mn) t[p].cnt+=t[p<<1|k].cnt;
}
int L,R,W;
void add(int p)
{
if(L<=t[p].l&&t[p].r<=R)
return setf(p,W);
pdn(p);
if(L<=t[p].mid) add(p<<1);
if(R>t[p].mid) add(p<<1|1);
pup(p);
}
void add(int l,int r,int w)
{
L=max(l,1),R=min(r,n),W=w;
ret(L>R);
// printf("add [%d,%d]:%d\n",L,R,w);
add(1);
// printf("???\n");
}
int qry()
{
return (t[1].mn==4?t[1].cnt:0);
}
}tr;
vct <int> a[N];
void work(int x,int y,int f)
{
// printf("%d,%d,%d\n",x,y,f);
int d[4]={a[x][y],a[x][y+1],a[x+1][y],a[x+1][y+1]};
sort(d,d+4);
tr.add(d[0],d[1]-1,f),tr.add(d[2],d[3]-1,f);
}
array <int,2> h[N];
void give_initial_chart(int d1_,int d2_,vct <int> z1,vct <int> z2)
{
d1=d1_,d2=d2_,n=d1*d2;
tr.bld(1,1,n);
For(i,0,d1+1)
{
a[i].resize(d2+2);
For(j,0,d2+1) a[i][j]=N;
}
For_(i,0,n) a[z1[i]+1][z2[i]+1]=i+1,h[i+1]={z1[i]+1,z2[i]+1};
For(i,0,d1) For(j,0,d2) work(i,j,1);
}
int swap_seats(int x,int y)
{
x++,y++;
For(k1,-1,0) For(k2,-1,0) work(h[x][0]+k1,h[x][1]+k2,-1);
For(k1,-1,0) For(k2,-1,0) work(h[y][0]+k1,h[y][1]+k2,-1);
swap(a[h[x][0]][h[x][1]],a[h[y][0]][h[y][1]]);
swap(h[x],h[y]);
For(k1,-1,0) For(k2,-1,0) work(h[x][0]+k1,h[x][1]+k2,1);
For(k1,-1,0) For(k2,-1,0) work(h[y][0]+k1,h[y][1]+k2,1);
return tr.qry();
}
详细
Subtask #1:
score: 0
Runtime Error
Test #1:
score: 0
Runtime Error
input:
3 3 5000 2 2 1 2 0 2 0 1 0 0 2 1 1 1 1 0 2 0 6 0 5 7 6 4 3 2 0 2 0 2 7 0 7 0 3 2 3 6 0 2 3 5 2 6 2 0 8 6 0 6 1 3 1 8 8 1 4 2 1 8 2 5 1 3 7 0 6 5 6 3 2 8 8 2 1 3 8 5 6 3 8 0 4 8 6 8 7 8 4 3 3 6 5 0 8 5 1 7 2 6 1 2 5 4 5 1 7 6 8 4 7 3 6 8 8 3 0 3 6 3 0 8 0 5 7 2 0 3 7 5 4 5 3 5 1 0 0 8 7 0 2 5 5 8 7 4...
output:
Unauthorized output
result:
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Skipped
Dependency #1:
0%
Subtask #4:
score: 0
Runtime Error
Test #33:
score: 0
Runtime Error
input:
101 101 5000 0 0 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 0 10 0 11 0 12 0 13 0 14 0 15 0 16 0 17 0 18 0 19 0 20 0 21 0 22 0 23 0 24 0 25 0 26 0 27 0 28 0 29 0 30 0 31 0 32 0 33 0 34 0 35 0 36 0 37 0 38 0 39 0 40 0 41 0 42 0 43 0 44 0 45 0 46 0 47 0 48 0 49 0 50 0 51 0 52 0 53 0 54 0 55 0 56 0 57 0 58 0 ...
output:
Unauthorized output
result:
Subtask #5:
score: 0
Runtime Error
Test #44:
score: 0
Runtime Error
input:
1 3 50000 0 1 0 2 0 0 0 2 2 0 2 1 0 1 1 0 0 1 1 2 1 2 1 2 0 2 1 0 0 2 2 0 1 2 2 1 2 0 0 1 0 2 1 2 1 0 1 0 1 2 0 1 1 0 0 2 0 2 2 1 0 2 1 0 1 2 2 1 2 1 1 2 0 1 1 2 0 1 0 2 1 2 0 2 2 1 2 0 1 2 1 0 1 0 2 1 1 0 1 0 2 1 1 2 0 2 2 0 1 0 2 0 0 2 1 0 0 2 1 2 2 1 0 1 0 2 1 0 2 1 2 0 1 2 0 1 2 0 2 1 2 0 0 2 1 ...
output:
Unauthorized output
result:
Subtask #6:
score: 0
Skipped
Dependency #1:
0%