Submission #3000208
Source Code Expand
#include<iostream> #include<string> #include<algorithm> #include<vector> #include<iomanip> #include<math.h> #include<complex> #include<queue> #include<deque> #include<map> #include<set> #include<bitset> using namespace std; #define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i ) #define rep(i,n) REP(i,0,n) typedef long long ll; typedef pair<int,int> pint; typedef pair<ll,int> pli; const int inf=1e9+7; const ll longinf=1LL<<60 ; const ll mod=1e9+7 ; int dx[4]={1,0,-1,0} , dy[4]={0,1,0,-1} ; struct BIT{ private: int sz; vector<ll> node; public: BIT(int n):sz(n),node(n+1){}; void add(int k,ll x){ k++; while(k<=sz){ node[k]+=x; k+=k&-k; } } ll sum(int k){ k++; ll ret=0; while(k>0){ ret+=node[k]; k-=k&-k; } return ret; } ll sum(int l,int r){ return sum(r-1)-sum(l-1); } ll get(int k){ return sum(k,k+1); } }; int main(){ int n,m; cin>>n>>m; pair<int,pint> p[n+m]; rep(i,n){ int l,r; cin>>l>>r; p[i]={r-l,{l,r}}; } rep(i,m)p[n+i]={i+1,{0,0}}; sort(p,p+n+m); BIT bit(m+1); int cnt=n; rep(i,m+n){ if(p[i].second.first){ bit.add(p[i].second.first,1); bit.add(p[i].second.second+1,-1); --cnt; } else{ int ret=cnt; for(int j=p[i].first;j<=m;j+=p[i].first){ ret+=bit.sum(j); } cout<<ret<<endl; } } return 0; }
Submission Info
Submission Time | |
---|---|
Task | E - Snuke Line |
User | tempura0224 |
Language | C++14 (GCC 5.4.1) |
Score | 700 |
Code Size | 1612 Byte |
Status | AC |
Exec Time | 355 ms |
Memory | 6400 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 | 2 ms | 256 KB |
04.txt | AC | 1 ms | 256 KB |
05.txt | AC | 3 ms | 256 KB |
06.txt | AC | 3 ms | 256 KB |
07.txt | AC | 1 ms | 256 KB |
08.txt | AC | 2 ms | 256 KB |
09.txt | AC | 1 ms | 256 KB |
10.txt | AC | 1 ms | 256 KB |
11.txt | AC | 240 ms | 4864 KB |
12.txt | AC | 354 ms | 6272 KB |
13.txt | AC | 173 ms | 3968 KB |
14.txt | AC | 159 ms | 3840 KB |
15.txt | AC | 159 ms | 3840 KB |
16.txt | AC | 219 ms | 4480 KB |
17.txt | AC | 346 ms | 6272 KB |
18.txt | AC | 154 ms | 3840 KB |
19.txt | AC | 355 ms | 6272 KB |
20.txt | AC | 354 ms | 6272 KB |
21.txt | AC | 351 ms | 6272 KB |
22.txt | AC | 349 ms | 6272 KB |
23.txt | AC | 349 ms | 6272 KB |
24.txt | AC | 347 ms | 6016 KB |
25.txt | AC | 187 ms | 3968 KB |
26.txt | AC | 162 ms | 3840 KB |
27.txt | AC | 348 ms | 6144 KB |
28.txt | AC | 190 ms | 4096 KB |
29.txt | AC | 351 ms | 6144 KB |
30.txt | AC | 198 ms | 4096 KB |
31.txt | AC | 344 ms | 6400 KB |
32.txt | AC | 188 ms | 4096 KB |
33.txt | AC | 162 ms | 3840 KB |
34.txt | AC | 354 ms | 6400 KB |
35.txt | AC | 349 ms | 6400 KB |
36.txt | AC | 1 ms | 256 KB |
37.txt | AC | 167 ms | 2432 KB |