Contest Duration: - (local time) (110 minutes) Back to Home

Submission #848044

Source Code Expand

Copy
```#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):x)
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

#ifdef DONLINE_JUDGE
// palindromic tree is better than splay tree!
#define lld I64d
#endif

struct /* ow the */ edge {
int v;
long long mult,rem;
edge() {}
edge(long long mult, int v, long long rem): v(v), mult(mult), rem(rem) {}
};

int main() {
cin.sync_with_stdio(0);
cin.tie(0);
cout << fixed << setprecision(10);
int N,Q;
cin >> N >> Q;
vector<long long> L(Q+1);
vector< vector<edge> > E(Q+1);
vector< vector<long long> > RMQ(17,vector<long long>(Q+1,2e18));
L[0] =RMQ[0][0] =N;
for(int q =0; q < Q; q++) {
long long x;
cin >> x;
L[q+1] =RMQ[0][q+1] =x;
int cur =q+1;
for(int i =1; i < 17; i++) if(q+2 >= (1<<i)) RMQ[i][q+1] =min(RMQ[i-1][q+1],RMQ[i-1][q+1-(1<<(i-1))]);
while(cur > 0 && x > 0) {
int nxt =-1;
//			for(int k =16; k >= 0; k--) if((1<<k) <= nxt+1 && RMQ[k][nxt] >= x) nxt -=(1<<k);
for(int i =cur-1; i >= 0; i--) if(L[i] < x) {
nxt =i;
break;}

//			cout << nxt << ".\n";
if(nxt == -1) {
E[q+1].push_back(edge(1,0,x));
break;}
E[q+1].push_back(edge(x/L[nxt],nxt,-1));
x =x%L[nxt];
cur =nxt;}
}
vector<long long> ans(N+1,0),mult(Q+1,0);
mult[Q] =1;
for(int q =Q; q >= 0; q--)
ALL_THE(E[q],it) {
if(it->rem == -1) mult[it->v] +=mult[q]*(it->mult);
else ans[it->rem] +=mult[q];}
for(int i =N; i >= 1; i--) ans[i-1] +=ans[i];
for(int i =1; i <= N; i++) cout << ans[i] << "\n";
return 0;}

// look at my code
// my code is amazing
```

#### Submission Info

Submission Time 2016-08-21 22:36:46+0900 E - Sequential operations on Sequence xellos C++14 (GCC 5.4.1) 0 2235 Byte WA 2107 ms 31088 KB

#### Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 1400
Status
 AC × 2
 AC × 4 WA × 4 TLE × 30
Set Name Test Cases
Sample s1.txt, s2.txt
All 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, s1.txt, s2.txt
Case Name Status Exec Time Memory
01.txt TLE 2104 ms 28528 KB
02.txt TLE 2107 ms 27504 KB
03.txt TLE 2103 ms 27760 KB
04.txt TLE 2104 ms 28016 KB
05.txt TLE 2104 ms 28272 KB
06.txt TLE 2103 ms 22000 KB
07.txt TLE 2103 ms 23024 KB
08.txt TLE 2103 ms 23024 KB
09.txt TLE 2103 ms 23664 KB
10.txt TLE 2103 ms 21872 KB
11.txt TLE 2103 ms 20848 KB
12.txt TLE 2103 ms 23024 KB
13.txt TLE 2103 ms 23536 KB
14.txt TLE 2103 ms 21616 KB
15.txt TLE 2103 ms 21232 KB
16.txt TLE 2103 ms 22512 KB
17.txt TLE 2103 ms 22640 KB
18.txt TLE 2107 ms 22000 KB
19.txt TLE 2103 ms 20592 KB
20.txt TLE 2103 ms 22640 KB
21.txt TLE 2104 ms 31088 KB
22.txt TLE 2103 ms 22896 KB
23.txt TLE 2103 ms 27376 KB
24.txt TLE 2103 ms 20464 KB
25.txt TLE 2103 ms 20464 KB
26.txt TLE 2103 ms 20464 KB
27.txt TLE 2103 ms 18544 KB
28.txt TLE 2103 ms 18544 KB
29.txt TLE 2103 ms 18544 KB
30.txt TLE 2103 ms 18544 KB
31.txt AC 4 ms 256 KB
32.txt WA 16 ms 1280 KB
33.txt AC 4 ms 256 KB
34.txt WA 16 ms 1280 KB
35.txt WA 4 ms 256 KB
36.txt WA 4 ms 256 KB
s1.txt AC 4 ms 256 KB
s2.txt AC 4 ms 256 KB