360病毒
(只会打暴力的人)
1
代码:
#include<bits/stdc++.h>
using namespace std;
int read(){
char c=getchar_unlocked();
int f=1;
while(!isdigit(c)){
if(c=='-') f=-1;
c=getchar_unlocked();
}
int k=0;
while(isdigit(c)){
k=(k<<3)+(k<<1)+(c^'0');
c=getchar_unlocked();
}
return f*k;
}
signed main(){
freopen("set.in","r",stdin);
freopen("set.out","w",stdout);
ios::sync_with_stdio(0);
cin.tie(0),cout.tie(0);
srand(time(0));
int c,t;
c=read(),t=read();
while(t--){
int n,m;
n=read(),m=read();
int hs[3000005]={};
for(int i=1;i<=m;i++){
long long mod=rand();
int k;
k=read();
for(int j=1;j<=k;j++){
int l,r;
l=read(),r=read();
hs[l]^=mod;
hs[r+1]^=mod;
}
}
for(int i=1;i<=n;i++)
hs[i]^=hs[i-1];
sort(hs+1,hs+n+1);
int ans=0;
for(int i=1;i<=n;i++){
if((i==1||hs[i]!=hs[i-1])&&(i==n||hs[i]!=hs[i+1]))
ans++;
}
cout<<ans<<'\n';
}
return 0;
}
题面:



CZF2919
(陈泽樊)
3
好像还不行,加上inline和register试试
曾天云
(曾天云)
16
#include<bits/stdc++.h>
using namespace std;
int read(){
char c=getchar_unlocked();
int f=1;
while(!isdigit(c)){
if(c==‘-’) f=-1;
c=getchar_unlocked();
}
int k=0;
while(isdigit(c)){
k=(k<<3)+(k<<1)+(c^‘0’);
c=getchar_unlocked();
}
return f*k;
}
int hs[3000005];
signed main(){
freopen(“set.in”,“r”,stdin);
freopen(“set.out”,“w”,stdout);
ios::sync_with_stdio(0);
cin.tie(0),cout.tie(0);
srand(time(0));
int c,t;
c=read(),t=read();
while(t–){
int n,m;
n=read(),m=read();
for(int i=1;i<=n;++i)hs[i]=0;
for(int i=1;i<=m;i++){
long long mod=rand();
int k;
k=read();
for(int j=1;j<=k;j++){
int l,r;
l=read(),r=read();
hs[l]^=mod;
hs[r+1]^=mod;
}
}
for(int i=1;i<=n;i++)
hs[i]^=hs[i-1];
sort(hs+1,hs+n+1);
int ans=0;
for(int i=1;i<=n;i++){
if((i==1||hs[i]!=hs[i-1])&&(i==n||hs[i]!=hs[i+1]))
ans++;
}
cout<<ans<<‘\n’;
}
return 0;
}
360病毒
(只会打暴力的人)
18
#include<bits/stdc++.h>
using namespace std;
int read(){
char c=getchar_unlocked();
int f=1;
while(!isdigit(c)){
if(c=='-') f=-1;
c=getchar_unlocked();
}
int k=0;
while(isdigit(c)){
k=(k<<3)+(k<<1)+(c^'0');
c=getchar_unlocked();
}
return f*k;
}
int hs[3000005];
signed main(){
// freopen("set.in","r",stdin);
// freopen("set.out","w",stdout);
ios::sync_with_stdio(0);
cin.tie(0),cout.tie(0);
srand(time(0));
int c,t;
c=read(),t=read();
while(t--){
int n,m;
n=read(),m=read();
memset(hs,0,sizeof(hs));
for(int i=1;i<=m;i++){
unsigned long long mod=rand();
int k;
k=read();
for(int j=1;j<=k;j++){
int l,r;
l=read(),r=read();
hs[l]^=mod;
hs[r+1]^=mod;
}
}
for(int i=2;i<=n;i++)
hs[i]^=hs[i-1];
sort(hs+1,hs+n+1);
int ans=0;
for(int i=1;i<=n;i++){
if((i==1||hs[i]!=hs[i-1])&&(i==n||hs[i]!=hs[i+1]))
ans++;
}
cout<<ans<<'\n';
}
return 0;
}
这下T的啥都不是)