QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#610023 | #9417. Palindromic Polygon | UESTC_NLNS# | WA | 11ms | 56188kb | C++14 | 1.8kb | 2024-10-04 14:44:06 | 2024-10-04 14:44:11 |
Judging History
answer
#include<bits/stdc++.h>
#define k1 (k<<1)
#define k2 (k<<1|1)
#define mid ((l+r)>>1)
#define ll long long
using namespace std;
const int N=5e5+5,M=N*20;
int TT,n,m,a,b,cnt[N],p[N][2];
ll ans;
bool check(int x)
{
if(p[x][0]+p[x][1]==cnt[x]&&p[x][1]==1) return true;
return false;
}
void add1(int x)
{
p[x][1]++;
if(check(x)) ans+=x*x;
return;
}
void add0(int x)
{
if(check(x)) ans-=x*x;
p[x][1]--;
p[x][0]++;
if(check(x)) ans+=x*x;
return;
}
class Segment_tree{
public:
vector<int> s[N<<2];
int sum[N<<2];
void update(int k)
{
if(sum[k]==1) for(auto i:s[k]) add1(i);
if(sum[k]==0) for(auto i:s[k]) add0(i);
return;
}
void clear(int k,int l,int r)
{
s[k].clear();
if(l==r) return;
clear(k1,l,mid);
clear(k2,mid+1,r);
return;
}
void build(int k,int l,int r)
{
sum[k]=r-l+1;
update(k);
if(l==r) return;
build(k1,l,mid);
build(k2,mid+1,r);
return;
}
void add_seg(int k,int l,int r,int x,int y,int t)
{
if(x<=l&&y>=r) {s[k].push_back(t);cnt[t]++;return;}
if(x<=mid) add_seg(k1,l,mid,x,y,t);
if(y>mid) add_seg(k2,mid+1,r,x,y,t);
return;
}
void modify(int k,int l,int r,int x)
{
sum[k]--;update(k);
if(l==r) return;
if(x<=mid) modify(k1,l,mid,x);
else modify(k2,mid+1,r,x);
return;
}
}T;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
cin>>TT;
while(TT--)
{
cin>>n>>m;ans=0;
for(int i=1;i<=m;i++) cnt[i]=p[i][0]=p[i][1]=0;
for(int i=1;i<=m;i++)
{
cin>>a>>b;a++;b++;
T.add_seg(1,1,n,a,b,i);
}
T.build(1,1,n);
cout<<ans<<" ";
for(int i=1;i<=n;i++)
{
cin>>a;
a=(a+ans)%n;a++;
T.modify(1,1,n,a);
cout<<ans<<" ";
}
cout<<"\n";
T.clear(1,1,n);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 11ms
memory: 56188kb
input:
3 8 2 4 2 4 3 4 5 3 2 3 0 6 -3 3 -3 0 -2 -3 1 -5 3 -3 4 0 3 1 2 3 0 0 1 0 0 1 3 1 1 1 0 0 1 0 0 1
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
result:
wrong answer 1st numbers differ - expected: '84', found: '0'