Submission #4570059
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
#define N 300010
int n,m,tot=0,root[N],ans[N];
struct node{int x,y;}a[N];
struct seg{int l,r,x;}t[N*100];
inline char gc(){
static char *S,*T,buf[1<<16];
if(T==S){T=(S=buf)+fread(buf,1,1<<16,stdin);if(T==S) return EOF;}
return *S++;
}
inline int read(){
int x=0,f=1;char ch=gc();
while(ch<'0' || ch>'9'){if(ch=='-') f=-1;ch=gc();}
while('0'<=ch && ch<='9') x=x*10+ch-'0',ch=gc();
return x*f;
}
inline bool cmp(node x,node y){
return x.x<y.x;
}
inline void ins(int &v,int l,int r,int x){
t[++tot]=t[v];v=tot;t[v].x++;
if(l==r) return;
int mid=l+r>>1;
if(x<=mid) ins(t[v].l,l,mid,x);
else ins(t[v].r,mid+1,r,x);
}
inline int query(int v1,int v2,int l,int r,int x,int y){
if(x<=l && r<=y) return t[v2].x-t[v1].x;
int mid=l+r>>1,s=0;
if(x<=mid) s+=query(t[v1].l,t[v2].l,l,mid,x,y);
if(mid<y) s+=query(t[v1].r,t[v2].r,mid+1,r,x,y);
return s;
}
int main(){
n=read();m=read();
for(int i=1;i<=n;++i){
a[i].x=read(),a[i].y=read();
}
sort(a+1,a+n+1,cmp);
for(int i=1,j=1;i<=m;++i){
root[i]=root[i-1];
while(j<=n && a[j].x==i) ins(root[i],1,m,a[j].y),++j;
}
// printf("%d\n",tot);
// for(int i=1;i<=m;++i) printf("%d ",root[i]);puts("");
// for(int i=1;i<=tot;++i) printf("%d %d %d %d\n",i,t[i].l,t[i].r,t[i].x);
printf("%d\n",n);
for(int i=2;i<=m;++i){
for(int j=i;j<=m;j+=i){
ans[i]+=query(root[j-i],root[j],1,m,j,m);
}
printf("%d\n",ans[i]);
}
return 0;
}
Submission Info
Submission Time |
|
Task |
E - Snuke Line |
User |
luogu_bot3 |
Language |
C++ (GCC 5.4.1) |
Score |
700 |
Code Size |
1437 Byte |
Status |
AC |
Exec Time |
266 ms |
Memory |
68992 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
700 / 700 |
Status |
|
|
Set Name |
Test Cases |
Sample |
00_example_01.txt, 00_example_02.txt |
All |
00_example_01.txt, 00_example_02.txt, 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, 37.txt |
Case Name |
Status |
Exec Time |
Memory |
00_example_01.txt |
AC |
3 ms |
4352 KB |
00_example_02.txt |
AC |
2 ms |
4352 KB |
01.txt |
AC |
2 ms |
4352 KB |
02.txt |
AC |
3 ms |
4480 KB |
03.txt |
AC |
3 ms |
4352 KB |
04.txt |
AC |
2 ms |
4352 KB |
05.txt |
AC |
3 ms |
4352 KB |
06.txt |
AC |
3 ms |
4352 KB |
07.txt |
AC |
2 ms |
2304 KB |
08.txt |
AC |
3 ms |
4352 KB |
09.txt |
AC |
3 ms |
4352 KB |
10.txt |
AC |
3 ms |
4352 KB |
11.txt |
AC |
127 ms |
62208 KB |
12.txt |
AC |
238 ms |
68864 KB |
13.txt |
AC |
69 ms |
53632 KB |
14.txt |
AC |
58 ms |
49536 KB |
15.txt |
AC |
59 ms |
49536 KB |
16.txt |
AC |
109 ms |
60032 KB |
17.txt |
AC |
235 ms |
68864 KB |
18.txt |
AC |
53 ms |
43264 KB |
19.txt |
AC |
266 ms |
68864 KB |
20.txt |
AC |
240 ms |
68864 KB |
21.txt |
AC |
242 ms |
68864 KB |
22.txt |
AC |
247 ms |
68864 KB |
23.txt |
AC |
250 ms |
68864 KB |
24.txt |
AC |
227 ms |
68608 KB |
25.txt |
AC |
78 ms |
55680 KB |
26.txt |
AC |
59 ms |
49408 KB |
27.txt |
AC |
260 ms |
68736 KB |
28.txt |
AC |
78 ms |
55680 KB |
29.txt |
AC |
237 ms |
68608 KB |
30.txt |
AC |
83 ms |
55680 KB |
31.txt |
AC |
188 ms |
68992 KB |
32.txt |
AC |
67 ms |
57728 KB |
33.txt |
AC |
55 ms |
51584 KB |
34.txt |
AC |
222 ms |
68992 KB |
35.txt |
AC |
231 ms |
68992 KB |
36.txt |
AC |
2 ms |
2304 KB |
37.txt |
AC |
125 ms |
4992 KB |