Submission #1356137
Source Code Expand
#include<bits/stdc++.h> using namespace std; int N, M; int x[101010]; int a[101010]; long long K; struct dat { int p1; int p2; int m; }; vector<dat> poly; dat pm(dat a, dat b, dat c) { dat res; res.p1 = res.p2 = res.m = 0; multiset<int> pp; pp.insert(a.p1); pp.insert(a.p2); pp.insert(b.p1); pp.insert(b.p2); pp.insert(c.m); multiset<int>::iterator it; it = pp.find(a.m); if(it!=pp.end()) pp.erase(it); else res.m = a.m; it = pp.find(b.m); if(it!=pp.end()) pp.erase(it); else res.m = b.m; it = pp.find(c.p1); if(it!=pp.end()) pp.erase(it); else res.m = c.p1; it = pp.find(c.p2); if(it!=pp.end()) pp.erase(it); else res.m = c.p2; res.p1 = *pp.begin(); if(pp.size()==2) res.p2 = *pp.rbegin(); return res; } vector<dat> conv(vector<dat> a, vector<dat> b) { vector<dat> res(N); for(int i=0; i<N; ++i) res[i] = pm(a[b[i].p1], a[b[i].p2], a[b[i].m]); return res; } vector<dat> pow(vector<dat> poly, long long x) { if(x==1) return poly; vector<dat> ans = pow(poly, x/2); ans = conv(ans, ans); if(x%2==1) ans = conv(ans, poly); return ans; } int main() { cin >> N; for(int i=0; i<N; ++i) cin >> x[i]; cin >> M >> K; for(int i=0; i<M; ++i) cin >> a[i]; for(int i=0; i<N; ++i) { dat a; a.p1 = 0; a.p2 = i; a.m = 0; poly.emplace_back(a); } for(int i=0; i<M; ++i) poly[a[i]-1] = pm(poly[a[i]], poly[a[i]-2], poly[a[i]-1]); vector<dat> res = pow(poly, K); for(int i=0; i<N; ++i) { //cout << res[i].p1 << res[i].p2 << res[i].m; cout << (long long)x[res[i].p1]+x[res[i].p2]-x[res[i].m] << ".0" << endl; } return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Rabbit Exercise |
User | HYEA |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1776 Byte |
Status | WA |
Exec Time | 2105 ms |
Memory | 76148 KB |
Judge Result
Set Name | Sample | All | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 800 | ||||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 0_00.txt, 0_01.txt, 0_02.txt |
All | 0_00.txt, 0_01.txt, 0_02.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt, 1_20.txt, 1_21.txt, 1_22.txt, 1_23.txt, 1_24.txt, 1_25.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_00.txt | AC | 1 ms | 256 KB |
0_01.txt | AC | 1 ms | 256 KB |
0_02.txt | AC | 1 ms | 256 KB |
1_00.txt | AC | 1 ms | 256 KB |
1_01.txt | AC | 1 ms | 256 KB |
1_02.txt | TLE | 2104 ms | 75764 KB |
1_03.txt | TLE | 2105 ms | 76148 KB |
1_04.txt | WA | 1852 ms | 51188 KB |
1_05.txt | WA | 30 ms | 896 KB |
1_06.txt | WA | 41 ms | 640 KB |
1_07.txt | WA | 46 ms | 1152 KB |
1_08.txt | WA | 57 ms | 1152 KB |
1_09.txt | WA | 60 ms | 1152 KB |
1_10.txt | WA | 19 ms | 548 KB |
1_11.txt | WA | 39 ms | 896 KB |
1_12.txt | WA | 5 ms | 384 KB |
1_13.txt | WA | 47 ms | 768 KB |
1_14.txt | WA | 43 ms | 896 KB |
1_15.txt | WA | 275 ms | 6720 KB |
1_16.txt | WA | 147 ms | 4480 KB |
1_17.txt | WA | 1129 ms | 31136 KB |
1_18.txt | WA | 1517 ms | 39800 KB |
1_19.txt | TLE | 2103 ms | 53748 KB |
1_20.txt | WA | 606 ms | 15740 KB |
1_21.txt | WA | 770 ms | 21372 KB |
1_22.txt | WA | 1972 ms | 52724 KB |
1_23.txt | TLE | 2104 ms | 62324 KB |
1_24.txt | WA | 1693 ms | 48248 KB |
1_25.txt | TLE | 2105 ms | 76148 KB |