Submission #2116394
Source Code Expand
#include <iostream> #include<vector> #include<algorithm> #include<queue> using namespace std; #define rep(i,n) for(int i=0;i<(int)(n);i++) #define REP(i,m,n) for(int i=m;i<(int)(n);i++) typedef pair<int,int> pint; typedef long long ll; const int inf = 1<<30; const int mod=1000000007; int edge[100001]; bool used[100001]; ll cnt; vector<int> v; void dfs (int i){ used[i]=true; v.push_back(i); cnt++; if(!used[edge[i]])dfs(edge[i]); } int main(){ int n;cin>>n; ll x[n]; rep(i,n)cin>>x[i]; rep(i,n-1)edge[i]=i; int m; ll k; cin>>m>>k; int a[m]; rep(i,m){ cin>>a[i]; swap(edge[a[i]-2],edge[a[i]-1]); } rep(i,n-1)used[i]=false; int dist[n-1]; rep(i,n-1){ if(!used[i]){ v.clear(); cnt=0; dfs(i); ll r=k%cnt; rep(j,cnt){ int fin=(j+r)%cnt; dist[v[j]]=x[v[fin]+1]-x[v[fin]]; } } } ll ans=x[0]; cout<<x[0]<<endl; rep(i,n-1){ ans+=dist[i]; cout<<ans<<endl; } return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Rabbit Exercise |
User | tempura0224 |
Language | C++14 (GCC 5.4.1) |
Score | 800 |
Code Size | 1066 Byte |
Status | AC |
Exec Time | 235 ms |
Memory | 6904 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 800 / 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 | AC | 204 ms | 2944 KB |
1_03.txt | AC | 235 ms | 6904 KB |
1_04.txt | AC | 168 ms | 3836 KB |
1_05.txt | AC | 7 ms | 384 KB |
1_06.txt | AC | 19 ms | 512 KB |
1_07.txt | AC | 12 ms | 384 KB |
1_08.txt | AC | 19 ms | 512 KB |
1_09.txt | AC | 19 ms | 512 KB |
1_10.txt | AC | 6 ms | 384 KB |
1_11.txt | AC | 12 ms | 384 KB |
1_12.txt | AC | 2 ms | 256 KB |
1_13.txt | AC | 21 ms | 512 KB |
1_14.txt | AC | 14 ms | 384 KB |
1_15.txt | AC | 41 ms | 768 KB |
1_16.txt | AC | 13 ms | 384 KB |
1_17.txt | AC | 115 ms | 1792 KB |
1_18.txt | AC | 134 ms | 2048 KB |
1_19.txt | AC | 170 ms | 2560 KB |
1_20.txt | AC | 72 ms | 1152 KB |
1_21.txt | AC | 82 ms | 1280 KB |
1_22.txt | AC | 171 ms | 2560 KB |
1_23.txt | AC | 177 ms | 2560 KB |
1_24.txt | AC | 128 ms | 1920 KB |
1_25.txt | AC | 204 ms | 2432 KB |