Submission #848103
Source Code Expand
Copy
#include <bits/stdc++.h> // iostream is too mainstream #include <cstdio> // bitch please #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(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 | |
---|---|
Task | E - Sequential operations on Sequence |
User | xellos |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 2229 Byte |
Status | WA |
Exec Time | 465 ms |
Memory | 43760 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 1400 | ||||||
Status |
|
|
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 | 465 ms | 42096 KB |
02.txt | WA | 342 ms | 42608 KB |
03.txt | WA | 325 ms | 40816 KB |
04.txt | WA | 341 ms | 41328 KB |
05.txt | WA | 342 ms | 41712 KB |
06.txt | WA | 203 ms | 30064 KB |
07.txt | WA | 226 ms | 34672 KB |
08.txt | WA | 216 ms | 31728 KB |
09.txt | WA | 230 ms | 34800 KB |
10.txt | WA | 205 ms | 30704 KB |
11.txt | WA | 198 ms | 29808 KB |
12.txt | WA | 228 ms | 34800 KB |
13.txt | WA | 227 ms | 34672 KB |
14.txt | WA | 205 ms | 30192 KB |
15.txt | WA | 201 ms | 29936 KB |
16.txt | WA | 218 ms | 31856 KB |
17.txt | WA | 220 ms | 31728 KB |
18.txt | WA | 212 ms | 30448 KB |
19.txt | WA | 203 ms | 29808 KB |
20.txt | WA | 216 ms | 31984 KB |
21.txt | AC | 298 ms | 43760 KB |
22.txt | WA | 209 ms | 30064 KB |
23.txt | WA | 262 ms | 37232 KB |
24.txt | WA | 168 ms | 25584 KB |
25.txt | WA | 169 ms | 25584 KB |
26.txt | AC | 161 ms | 24688 KB |
27.txt | AC | 115 ms | 21616 KB |
28.txt | AC | 115 ms | 21616 KB |
29.txt | AC | 114 ms | 21616 KB |
30.txt | WA | 135 ms | 24688 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 | 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 |