AtCoder Regular Contest 068

Submission #4014302

Source codeソースコード

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<math.h>
using namespace std;

const int N=1e5+5;
const int M=3e5+5;
const int T=5e6+5;
int n,m,st[M],en[M];
pair<int,int> p[N];

struct Chairman_Tree
{
	int seg_tot,rt[N];
	struct node
	{
		int lsn,rsn,cnt;
	};
	node seg[T];
	
	void update(int &rt,int las,int l,int r,int pos)
	{
		seg[rt=++seg_tot]=seg[las];
		++seg[rt].cnt;
		if(l==r) return;
		int mid=(l+r)>>1;
		if(pos<=mid) update(seg[rt].lsn,seg[las].lsn,l,mid,pos);
		else update(seg[rt].rsn,seg[las].rsn,mid+1,r,pos);
	}
	
	int query(int rt,int las,int l,int r,int L,int R)
	{
		if(L<=l&&r<=R) return seg[rt].cnt-seg[las].cnt;
		int mid=(l+r)>>1;int ret=0;
		if(L<=mid) ret+=query(seg[rt].lsn,seg[las].lsn,l,mid,L,R);
		if(R>mid) ret+=query(seg[rt].rsn,seg[las].rsn,mid+1,r,L,R);
		return ret;
	}
};
Chairman_Tree SS;

void init()
{
	int i,now=0;
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;++i)
		scanf("%d%d",&p[i].first,&p[i].second);
	sort(p+1,p+n+1);
	
	for(i=1;i<=m;++i)
	{
		st[i]=now+1;
		while(p[now+1].first==i) ++now;
		en[i]=now;
	}
	
	for(i=1;i<=n;++i)
		SS.update(SS.rt[i],SS.rt[i-1],1,m,p[i].second);
}

int calc(int x,int y,int l,int r)
{
	return SS.query(SS.rt[en[y]],SS.rt[st[x]-1],1,m,l,r);
}

void work()
{
	int i,j,ans=0;
	for(i=1;i<=m;++i)
	{
		ans=0;
		for(j=i;j<=m;j+=i)
			ans+=calc(j-i+1,j,j,m);
		printf("%d\n",ans);
	}
}

int main()
{
	init();work();
	return 0;
}

Submission

Task問題 E - Snuke Line
User nameユーザ名 hwk0518
Created time投稿日時
Language言語 C++ (GCC 5.4.1)
Status状態 WA
Score得点 0
Source lengthソースコード長 1546 Byte
File nameファイル名
Exec time実行時間 ms
Memory usageメモリ使用量 -

Compiler messageコンパイルメッセージ

./Main.cpp: In function ‘void init()’:
./Main.cpp:49:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d",&n,&m);
^
./Main.cpp:51:41: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d",&p[i].first,&p[i].second);
^

Test case

Set

Set name Score得点 / Max score Cases
Sample - 00_example_01.txt,00_example_02.txt
All 0 / 700 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

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
00_example_01.txt AC 2 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 2 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 4352 KB
08.txt AC 3 ms 4352 KB
09.txt AC 2 ms 4352 KB
10.txt AC 2 ms 4352 KB
11.txt WA
12.txt WA
13.txt WA
14.txt WA
15.txt WA
16.txt WA
17.txt WA
18.txt WA
19.txt WA
20.txt WA
21.txt WA
22.txt WA
23.txt WA
24.txt WA
25.txt WA
26.txt WA
27.txt WA
28.txt WA
29.txt WA
30.txt WA
31.txt WA
32.txt WA
33.txt WA
34.txt WA
35.txt WA
36.txt AC 2 ms 4352 KB
37.txt AC 140 ms 4480 KB