Submission #1619641
Source Code Expand
#include <cstdio>
#include <cstring>
#define MAXN 100010
#define LL long long
int n,m;
LL v[MAXN],ans[MAXN],K;
int a[MAXN];
int p[MAXN];
bool visit[MAXN];
void gao(int x){
static int b[MAXN];
int numb=0;
b[numb++]=x;
visit[x]=1;
for(int i=a[x];i^x;i=a[i]){
b[numb++]=i;
visit[i]=1;
}
for(int i=0;i<numb;i++){
int x=b[i];
p[x]=b[(K+i)%numb];
}
}
int main(){
scanf("%d",&n);
for(int i=1;i<=n;i++) scanf("%lld",v+i),a[i]=i;
for(int i=n;i>=2;i--) v[i]-=v[i-1];
scanf("%d%lld",&m,&K);
while(m--){
int t;
scanf("%d",&t);
a[t]^=a[t+1]^=a[t]^=a[t+1];
}
for(int i=1;i<=n;i++)
if(!visit[i])
gao(i);
for(int i=1;i<=n;i++)
ans[i]=v[p[i]];
for(int i=2;i<=n;i++)
ans[i]+=ans[i-1];
for(int i=1;i<=n;i++) printf("%.1lf\n",(double)ans[i]);
}
Submission Info
Submission Time |
|
Task |
A - Prefix and Suffix |
User |
ez_zjt |
Language |
C++14 (GCC 5.4.1) |
Score |
0 |
Code Size |
814 Byte |
Status |
WA |
Exec Time |
1 ms |
Memory |
128 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:28:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&n);
^
./Main.cpp:29:48: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
for(int i=1;i<=n;i++) scanf("%lld",v+i),a[i]=i;
^
./Main.cpp:31:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%lld",&m,&K);
^
./Main.cpp:34:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&t);
^
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
0 / 200 |
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 |
Case Name |
Status |
Exec Time |
Memory |
0_00.txt |
WA |
1 ms |
128 KB |
0_01.txt |
WA |
0 ms |
128 KB |
0_02.txt |
WA |
1 ms |
128 KB |
1_00.txt |
WA |
1 ms |
128 KB |
1_01.txt |
WA |
1 ms |
128 KB |
1_02.txt |
WA |
1 ms |
128 KB |
1_03.txt |
WA |
1 ms |
128 KB |
1_04.txt |
WA |
1 ms |
128 KB |
1_05.txt |
WA |
1 ms |
128 KB |