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

Submission #847973

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 =cur-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:34:00+0900 E - Sequential operations on Sequence xellos C++14 (GCC 5.4.1) 0 2240 Byte WA 337 ms 43760 KB

#### Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 1400
Status
 AC × 2
 AC × 9 WA × 29
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 WA 328 ms 38768 KB
02.txt WA 337 ms 38768 KB
03.txt WA 325 ms 37744 KB
04.txt WA 334 ms 38128 KB
05.txt WA 323 ms 38384 KB
06.txt WA 197 ms 27504 KB
07.txt WA 208 ms 29296 KB
08.txt WA 204 ms 29168 KB
09.txt WA 214 ms 30448 KB
10.txt WA 195 ms 27376 KB
11.txt WA 180 ms 25712 KB
12.txt WA 202 ms 29296 KB
13.txt WA 206 ms 30320 KB
14.txt WA 187 ms 26864 KB
15.txt WA 182 ms 26224 KB
16.txt WA 195 ms 28400 KB
17.txt WA 197 ms 28528 KB
18.txt WA 191 ms 27504 KB
19.txt WA 180 ms 25072 KB
20.txt WA 197 ms 28656 KB
21.txt AC 306 ms 43760 KB
22.txt WA 209 ms 29680 KB
23.txt WA 254 ms 36848 KB
24.txt WA 173 ms 25456 KB
25.txt WA 164 ms 24688 KB
26.txt AC 167 ms 24688 KB
27.txt AC 117 ms 21616 KB
28.txt AC 115 ms 21616 KB
29.txt AC 120 ms 21616 KB
30.txt WA 123 ms 21616 KB
31.txt AC 4 ms 256 KB
32.txt WA 17 ms 1280 KB
33.txt AC 4 ms 256 KB
34.txt WA 17 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