QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#360427 | #5441. Quartz Collection | qwqUwU_ | WA | 2ms | 4840kb | C++14 | 3.1kb | 2024-03-21 19:23:15 | 2024-03-21 19:23:15 |
Judging History
answer
// clang-format off
#include<bits/stdc++.h>
#define pb push_back
#define P make_pair
#define st first
#define nd second
#define bit(s,x) (((s)>>(x))&1)
#define ctz(s) __builtin_popcount(s)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
//typedef __int128 i128;
typedef long double ld;
typedef pair<int,int> pii; typedef pair<ll,int> pli; typedef pair<ll,ll> pll; typedef pair<int,ll> pil;
inline ll read(){
ll x=0,f=1,c=getchar();
while(c<'0'||c>'9')f=(c=='-'?-1:1),c=getchar();
while(c>='0'&&c<='9')x=(x<<1)+(x<<3)+(c^48),c=getchar();
return x*f;
}
inline void write(ll x){ if(x<0) putchar('-'),x=-x; if(x>9) write(x/10); putchar(x%10+'0'); }
// remember to change!!!
const int mod=998244353;
inline void plust(int &x,int y,int p=mod){x=x+y<p?x+y:x+y-p;}
inline void mul(int &x,int y,int p=mod){x=1ll*x*y%p;}
inline int fp(int x,ll p=mod-2,int m=mod,int res=1){
for(;p;p>>=1){if(p&1)mul(res,x,m);mul(x,x,m);}
return res;
}
const int N=1e5+10;
const int INF=0x3fffffff;
// clang-format on
pii a[N];
struct info1{ll a[2];int siz;}t[1<<18];
info1 operator +(info1 A,info1 B){
info1 res;res.siz = A.siz + B.siz;
for(int i=0;i<2;++i)res.a[i] = A.a[i] + B.a[(i+A.siz)%2];
return res;
}
info1 operator -(info1 A,info1 B){
info1 res;res.siz = A.siz - B.siz;
for(int i=0;i<2;++i)res.a[i] = A.a[i] - B.a[(i+res.siz)%2];
return res;
}
struct info2{ll a[4];int siz;}p[1<<18];
info2 operator +(info2 A,info2 B){
info2 res;res.siz = A.siz + B.siz;
for(int i=0;i<4;++i)res.a[i] = A.a[i] + B.a[(i+A.siz)%4];
return res;
}
info2 operator -(info2 A,info2 B){
info2 res;res.siz = A.siz - B.siz;
for(int i=0;i<4;++i)res.a[i] = A.a[i] - B.a[(i+res.siz)%4];
return res;
}
#define mid ((l+r)>>1)
inline void update1(int x,int l,int r,int nx,info1 k,int op){
if(l==r){
if(op==1)t[x] = t[x] + k;
else t[x] = t[x] - k;
return ;
}
if(nx<=mid)update1(x<<1,l,mid,nx,k,op);
else update1(x<<1|1,mid+1,r,nx,k,op);
t[x] = t[x<<1] + t[x<<1|1];
}
inline void update2(int x,int l,int r,int nx,info2 k,int op){
if(l==r){
if(op==1)p[x] = p[x] + k;
else p[x] = p[x] - k;
return ;
}
if(nx<=mid)update2(x<<1,l,mid,nx,k,op);
else update2(x<<1|1,mid+1,r,nx,k,op);
p[x] = p[x<<1|1] + p[x<<1];
}
int main() {
//freopen("data.in", "r", stdin);
// freopen(".in","r",stdin);
// freopen("myans.out","w",stdout);
int n=read(),T=read();
for(int i=1;i<=n;++i){
a[i].st=read(),a[i].nd=read();
if(a[i].st >= a[i].nd)update1(1,0,n,a[i].st-a[i].nd,{{a[i].st,a[i].nd},1},1);
else update2(1,0,n,a[i].nd-a[i].st,{{a[i].st,a[i].nd,a[i].nd,a[i].st},1},1);
}
int s=p[1].siz;
printf("%lld\n",p[1].a[0] + t[1].a[s&1]);
while(T--){
int i=read();
if(a[i].st >= a[i].nd)update1(1,0,n,a[i].st-a[i].nd,{{a[i].st,a[i].nd},1},-1);
else update2(1,0,n,a[i].nd-a[i].st,{{a[i].st,a[i].nd,a[i].nd,a[i].st},1},-1);
a[i].st=read(),a[i].nd=read();
if(a[i].st >= a[i].nd)update1(1,0,n,a[i].st-a[i].nd,{{a[i].st,a[i].nd},1},1);
else update2(1,0,n,a[i].nd-a[i].st,{{a[i].st,a[i].nd,a[i].nd,a[i].st},1},1);
s=p[1].siz;
printf("%lld\n",p[1].a[0] + t[1].a[s&1]);
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3936kb
input:
4 5 2 4 5 7 1 7 2 1 4 5 2 1 6 2 4 4 3 2 1 3 3 6 6
output:
13 14 15 14 10 13
result:
ok 6 numbers
Test #2:
score: 0
Accepted
time: 0ms
memory: 3884kb
input:
1 1 1 1 1 1 1
output:
1 1
result:
ok 2 number(s): "1 1"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3864kb
input:
100 100 6 7 100 8 5 61 5 75 59 65 51 47 83 37 34 54 87 46 4 26 21 87 12 97 86 68 60 11 62 76 14 83 29 31 91 62 57 80 47 75 85 97 62 77 91 86 14 25 48 77 83 65 39 61 78 77 45 46 90 74 100 91 86 98 55 5 84 42 91 69 100 4 74 98 60 37 75 44 41 12 15 34 36 1 99 16 7 87 36 26 79 42 41 84 17 98 72 16 38 55...
output:
5109 5065 5060 5007 4975 4993 4950 4928 4922 4930 4948 4915 4885 4863 4898 4864 4837 4787 4793 4774 4730 4708 4659 4617 4546 4618 4654 4687 4677 4685 4714 4733 4728 4701 4660 4631 4628 4682 4743 4777 4764 4772 4754 4759 4715 4744 4672 4687 4700 4649 4611 4543 4523 4554 4605 4585 4532 4520 4489 4505 ...
result:
ok 101 numbers
Test #4:
score: 0
Accepted
time: 1ms
memory: 3932kb
input:
1000 1000 411 789 753 186 495 203 417 324 490 424 195 480 314 23 663 218 12 747 124 390 134 38 218 536 291 840 174 908 474 767 313 167 575 9 857 427 313 27 959 935 258 70 472 957 747 228 205 939 293 303 626 802 712 283 658 346 208 383 889 204 99 640 801 966 828 742 534 11 259 734 226 129 843 350 50 ...
output:
490601 490340 490353 490689 490697 490600 490571 491078 491388 491507 491729 491809 491984 492228 492161 492171 492384 492276 492693 492547 492372 492580 492350 492795 492635 492941 492936 492797 492359 492108 492670 492589 492570 492700 492910 492401 492274 492263 491905 491692 492032 492168 492350...
result:
ok 1001 numbers
Test #5:
score: -100
Wrong Answer
time: 2ms
memory: 4840kb
input:
5000 1000 72520 61541 4609 95655 27768 67682 48763 4836 63868 3082 44496 5022 70138 88832 25864 48681 5212 79532 1134 60190 84561 98392 91027 55707 72938 83316 60044 93249 82269 88819 83951 6069 35302 29132 1882 68479 3489 45817 79436 37261 88849 763 23786 62641 89532 32244 85372 46815 6765 56651 27...
output:
250338255 249869380 249882986 250341875 249844305 249899243 250370567 250424634 250459823 250426141 250485507 250490200 250073235 250446703 250422198 250429570 250446180 250082986 250105317 250050070 250460805 250093529 250063048 250050466 250001633 249997017 250292519 250017495 250043906 250035959 ...
result:
wrong answer 1st numbers differ - expected: '249456797', found: '250338255'