QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#610876 | #9409. Sensors | UESTC_Snow_Halation | AC ✓ | 1286ms | 208956kb | C++14 | 2.7kb | 2024-10-04 17:53:48 | 2024-10-04 17:53:48 |
Judging History
answer
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#define FOR() ll le=e[u].size();for(ll i=0;i<le;i++)
#define QWQ cout<<"QwQ\n";
#define ll long long
#include <vector>
#include <queue>
#include <map>
#define ls now<<1
#define rs now<<1|1
using namespace std;
const ll N=501010;
const ll qwq=303030;
const ll inf=0x3f3f3f3f;
inline ll read() {
ll sum = 0, ff = 1; char c = getchar();
while(c<'0' || c>'9') { if(c=='-') ff = -1; c = getchar(); }
while(c>='0'&&c<='9') { sum = sum * 10 + c - '0'; c = getchar(); }
return sum * ff;
}
ll T;
ll n,m;
vector <ll> g[N<<2];
ll t[N<<2];
ll yi[N],ling[N],siz[N];
ll ans;
void check(ll now,ll cl) {
// cout<<"check("<<now<<","<<cl<<")\n";
if(cl==1) {
for(ll v : g[now]) {
yi[v]++;
// cout<<" v = "<<v<<" yi = "<<yi[v]<<" ling = "<<ling[v]<<" siz = "<<siz[v]<<"\n";
if(yi[v]==1 && ling[v]==siz[v]-1) ans += v*v;//, cout<<" + "<<v<<"\n";
}
}
else {
for(ll v : g[now]) {
// cout<<" v = "<<v<<" yi = "<<yi[v]<<" ling = "<<ling[v]<<" siz = "<<siz[v]<<"\n";
if(yi[v]==1 && ling[v]==siz[v]-1) ans -= v*v;//, cout<<" - "<<v<<"\n";
yi[v]--;
ling[v]++;
if(yi[v]==1 && ling[v]==siz[v]-1) ans += v*v;//, cout<<" + "<<v<<"\n";
}
}
}
void built(ll now,ll l,ll r) {
if(l==r) { t[now] = 1; return ; }
ll mid = l+r >> 1;
built(ls, l, mid);
built(rs, mid+1, r);
t[now] += t[ls] + t[rs];
}
void update(ll now,ll l,ll r,ll x) {
t[now]--;
if(t[now]==1 || t[now]==0) check(now,t[now]);
if(l==r) return ;
ll mid = l+r >> 1;
if(x<=mid) update(ls, l, mid, x);
else update(rs, mid+1, r, x);
}
void insert(ll now,ll l,ll r,ll x,ll y,ll i) {
if(x<=l && r<=y) {
if(l==r) yi[i]++;
g[now].push_back(i);
siz[i]++;
return ;
}
ll mid = l+r >> 1;
if(x<=mid) insert(ls, l, mid, x, y, i);
if(y>mid) insert(rs, mid+1, r, x, y, i);
}
void chushihua() {
ans = 0;
for(ll i=1;i<=m;i++) yi[i] = ling[i] = siz[i] = 0;
for(ll i=1;i<=4*n;i++) t[i] = 0, g[i].clear();
}
int main() {
ll x,y;
T = read();
while(T--) {
chushihua();
n = read(); m = read();
built(1, 1, n);
for(ll i=1;i<=m;i++) {
x = read()+1; y = read()+1;
if(x==y) ans += i*i;
insert(1, 1, n, x, y, i);
}
// for(int i=1;i<=9;i++) {
// cout<<"I = "<<i<<" \n";
// for(int v : g[i]) cout<<v<<" ";
// cout<<endl;
// }
cout<<ans<<" ";
for(ll i=1;i<=n;i++) {
// cout<<i<<" : \n";
x = (read()+ans) %n + 1;
// cout<<"x = "<<x<<"\n";
update(1, 1, n, x);
cout<<ans<<" ";
}
cout<<endl;
}
return 0;
}
/*
3
5 4
2 4
2 3
3 3
0 2 3 2 4 2 0
2 1
1 1
1 0
2 1
0 1
0 0
*/
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 7ms
memory: 54924kb
input:
3 5 4 2 4 2 3 3 3 0 2 3 2 4 2 0 2 1 1 1 1 0 2 1 0 1 0 0
output:
9 13 29 17 16 0 1 1 0 0 1 0
result:
ok 3 lines
Test #2:
score: 0
Accepted
time: 460ms
memory: 78472kb
input:
2227 2 9 0 1 1 1 0 1 0 0 0 1 0 1 0 0 1 1 0 1 1 1 3 1 0 2 1 2 2 8 2 0 2 3 5 7 4 0 3 2 6 4 1 6 2 1 3 0 1 0 0 5 1 4 2 1 6 0 0 0 0 0 0 0 0 0 0 0 0 0 5 1 1 4 0 1 2 3 3 5 3 0 3 4 4 2 2 0 4 0 0 0 5 10 0 2 3 3 1 3 1 4 1 3 0 4 2 4 0 0 0 1 4 4 3 1 3 4 1 8 4 0 5 0 1 6 7 3 4 1 3 3 5 2 3 5 3 2 7 1 1 0 0 0 0 1 1 ...
output:
133 220 0 0 0 1 0 0 0 0 0 4 4 5 4 0 0 4 4 4 4 5 0 91 0 0 0 0 0 1 0 13 13 4 0 1 0 168 249 105 135 136 0 0 4 13 9 0 0 16 17 0 79 127 0 1 54 0 0 0 25 25 25 61 40 57 21 14 0 385 0 0 0 9 71 9 53 69 0 0 0 9 9 9 46 0 35 39 203 0 1 10 9 9 9 54 0 5 5 5 0 0 5 13 13 4 16 16 16 0 4 4 5 5 5 4 ...
result:
ok 2227 lines
Test #3:
score: 0
Accepted
time: 1286ms
memory: 166116kb
input:
1 500000 500000 369902 382967 262235 295509 296241 456925 21398 104992 37225 97384 380549 388723 338331 494405 150247 262207 70049 286642 214690 432702 268101 392964 99683 217894 89569 351594 126467 380939 152103 169827 171887 422097 166531 416410 44667 160325 210347 371355 47557 119914 74437 200422...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok single line: '0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...9642788310 20801182804434259 0 '
Test #4:
score: 0
Accepted
time: 184ms
memory: 77408kb
input:
1 500000 500000 0 499999 0 499999 0 499999 0 499999 0 499999 0 499999 0 499999 0 499999 0 499999 0 499999 0 499999 0 499999 0 499999 0 499999 0 499999 0 499999 0 499999 0 499999 0 499999 0 499999 0 499999 0 499999 0 499999 0 499999 0 499999 0 499999 0 499999 0 499999 0 499999 0 499999 0 499999 0 499...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok single line: '0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ... 0 0 0 0 0 41666791666750000 0 '
Test #5:
score: 0
Accepted
time: 402ms
memory: 208956kb
input:
1 500000 500000 1 499998 1 499998 1 499998 1 499998 1 499998 1 499998 1 499998 1 499998 1 499998 1 499998 1 499998 1 499998 1 499998 1 499998 1 499998 1 499998 1 499998 1 499998 1 499998 1 499998 1 499998 1 499998 1 499998 1 499998 1 499998 1 499998 1 499998 1 499998 1 499998 1 499998 1 499998 1 499...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok single line: '0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ... 0 0 0 0 0 41666791666750000 0 '
Test #6:
score: 0
Accepted
time: 451ms
memory: 117432kb
input:
1 500000 250000 0 250000 1 250001 2 250002 3 250003 4 250004 5 250005 6 250006 7 250007 8 250008 9 250009 10 250010 11 250011 12 250012 13 250013 14 250014 15 250015 16 250016 17 250017 18 250018 19 250019 20 250020 21 250021 22 250022 23 250023 24 250024 25 250025 26 250026 27 250027 28 250028 29 2...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok single line: '0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...18019441588 4838325779633316 0 '
Extra Test:
score: 0
Extra Test Passed