Submission #4023152
Source Code Expand
#include <bits/stdc++.h> #define mset(a, b) memset(a, b, sizeof(a)) #define lc rt<<1 #define rc (rt<<1)|1 using namespace std; typedef long long LL; const int MAXN = 100005; const int INF = 0x3f3f3f3f; template <typename T> inline void read(T &AKNOI) { T x=0, flag=1; char ch = getchar(); while(!isdigit(ch)){ if(ch == '-') flag = -1; ch = getchar(); } while(isdigit(ch)){ x = (x<<1) + (x<<3) + ch - '0'; ch = getchar(); } AKNOI = flag*x; } int n, m, tr[MAXN]; struct Area { int l, r, len; bool operator < (const Area &rhs) const { return len < rhs.len; } }a[MAXN*3]; inline int lowbit(int x) { return x & (-x); } inline void add(int x, int val) { for(int i=x;i;i-=lowbit(i)){ tr[i] += val; } } inline void update(int l, int r) { add(l-1, -1); add(r, 1); } inline int query(int x) { int ret = 0; for(int i=x;i<=m;i+=lowbit(i)){ ret += tr[i]; } return ret; } void init() { read(n); read(m); for(int i=1;i<=n;++i){ read(a[i].l); read(a[i].r); a[i].len = a[i].r - a[i].l + 1; } sort(a+1, a+n+1); } void solve() { for(int i=1,j=1;i<=m;++i){ while(j<=n && a[j].len == i){ update(a[j].l, a[j].r); ++j; } int ans = n-j+1; for(int k=i;k<=m;k+=i){ ans += query(k); } printf("%d\n", ans); } } int main() { init(); solve(); return 0; }
Submission Info
Submission Time | |
---|---|
Task | E - Snuke Line |
User | luogu_bot2 |
Language | C++ (GCC 5.4.1) |
Score | 700 |
Code Size | 1439 Byte |
Status | AC |
Exec Time | 80 ms |
Memory | 4864 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 | 1 ms | 256 KB |
00_example_02.txt | AC | 1 ms | 256 KB |
01.txt | AC | 1 ms | 256 KB |
02.txt | AC | 2 ms | 256 KB |
03.txt | AC | 1 ms | 256 KB |
04.txt | AC | 1 ms | 256 KB |
05.txt | AC | 2 ms | 256 KB |
06.txt | AC | 2 ms | 256 KB |
07.txt | AC | 1 ms | 256 KB |
08.txt | AC | 1 ms | 256 KB |
09.txt | AC | 1 ms | 256 KB |
10.txt | AC | 1 ms | 256 KB |
11.txt | AC | 59 ms | 4224 KB |
12.txt | AC | 77 ms | 4736 KB |
13.txt | AC | 46 ms | 3840 KB |
14.txt | AC | 43 ms | 3840 KB |
15.txt | AC | 43 ms | 3840 KB |
16.txt | AC | 55 ms | 4096 KB |
17.txt | AC | 76 ms | 4736 KB |
18.txt | AC | 42 ms | 3712 KB |
19.txt | AC | 77 ms | 4736 KB |
20.txt | AC | 77 ms | 4736 KB |
21.txt | AC | 77 ms | 4736 KB |
22.txt | AC | 77 ms | 4736 KB |
23.txt | AC | 80 ms | 4736 KB |
24.txt | AC | 67 ms | 4480 KB |
25.txt | AC | 43 ms | 3840 KB |
26.txt | AC | 39 ms | 3840 KB |
27.txt | AC | 71 ms | 4608 KB |
28.txt | AC | 47 ms | 3840 KB |
29.txt | AC | 75 ms | 4352 KB |
30.txt | AC | 49 ms | 3840 KB |
31.txt | AC | 68 ms | 4480 KB |
32.txt | AC | 44 ms | 3840 KB |
33.txt | AC | 41 ms | 3840 KB |
34.txt | AC | 67 ms | 4864 KB |
35.txt | AC | 67 ms | 4864 KB |
36.txt | AC | 1 ms | 256 KB |
37.txt | AC | 25 ms | 512 KB |