Submission #5539625


Source Code Expand

#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
using namespace std;
#define fi first
#define se second
#define pb push_back
typedef pair<int, int> ii;
typedef long long ll;

const int maxn = 3e5+5;

struct node
{
	int t, L, R, det;
	node(){}
	node(int t, int L, int R): t(t), L(L), R(R)
	{
		if(t == 1) det = R-L;
		else det = L;
	}
	bool operator < (node other) const
	{
		if(det != other.det) return det> other.det;
		return t< other.t;
	}
};

int ft[maxn];
int n, m;

void update(int x, int dx)
{
	for(; x<= n; x += x&(-x)) ft[x] += dx;
}

int sum(int x)
{
	int res = 0;
	for(; x; x -= x&(-x)) res += ft[x];
	return res;
}

vector<node> vec;

int st[maxn], ed[maxn];
int ans[maxn];

int main()
{
	scanf("%d %d", &m, &n);
	for(int i = 1; i<= n; i++) vec.pb(node(2, i, i));
	for(int i = 1; i<= m; i++)
	{
		scanf("%d %d", &st[i], &ed[i]);
		update(st[i], 1);
		update(ed[i]+1, -1);
		vec.pb(node(1, st[i], ed[i]));
	}
	sort(vec.begin(), vec.end());
	int over = 0;
	for(auto kk : vec)
	{
		int t = kk.t;
		int L = kk.L;
		int R = kk.R;
		if(t == 1)
		{
			update(L, -1);
			update(R+1, 1);
			over++;
		}
		else
		{
			int x = L;
			int res = 0;
			for(int y = 0; y<= n; y += x)
			{
				res += sum(y);
			}
			ans[x] = over+res;
		}
	}
	for(int i = 1; i<= n; i++) printf("%d\n", ans[i]);
}

Submission Info

Submission Time
Task E - Snuke Line
User Crown
Language C++14 (GCC 5.4.1)
Score 700
Code Size 1408 Byte
Status AC
Exec Time 156 ms
Memory 13548 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:51:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &m, &n);
                        ^
./Main.cpp:55:33: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &st[i], &ed[i]);
                                 ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 700 / 700
Status
AC × 2
AC × 39
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 2 ms 2304 KB
00_example_02.txt AC 1 ms 2304 KB
01.txt AC 1 ms 2304 KB
02.txt AC 2 ms 2432 KB
03.txt AC 2 ms 2304 KB
04.txt AC 2 ms 2304 KB
05.txt AC 2 ms 2304 KB
06.txt AC 2 ms 2304 KB
07.txt AC 2 ms 2304 KB
08.txt AC 2 ms 2304 KB
09.txt AC 2 ms 2304 KB
10.txt AC 2 ms 2304 KB
11.txt AC 125 ms 12396 KB
12.txt AC 155 ms 12396 KB
13.txt AC 107 ms 12908 KB
14.txt AC 99 ms 11500 KB
15.txt AC 99 ms 13164 KB
16.txt AC 118 ms 13292 KB
17.txt AC 156 ms 13292 KB
18.txt AC 95 ms 11628 KB
19.txt AC 156 ms 12652 KB
20.txt AC 156 ms 13036 KB
21.txt AC 155 ms 12908 KB
22.txt AC 156 ms 13164 KB
23.txt AC 156 ms 11500 KB
24.txt AC 137 ms 11500 KB
25.txt AC 99 ms 12396 KB
26.txt AC 95 ms 13420 KB
27.txt AC 140 ms 11500 KB
28.txt AC 102 ms 12908 KB
29.txt AC 144 ms 12396 KB
30.txt AC 100 ms 13548 KB
31.txt AC 136 ms 13036 KB
32.txt AC 100 ms 11884 KB
33.txt AC 94 ms 12908 KB
34.txt AC 138 ms 11500 KB
35.txt AC 138 ms 12012 KB
36.txt AC 2 ms 2304 KB
37.txt AC 45 ms 4592 KB