Submission #1613176


Source Code Expand

#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>

typedef long long LL;
const int MX=100011;

int p[MX],x[MX],a[MX];
int n,m;LL k;
LL ans[MX];

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&x[i]);
	for(int i=1;i<=n;i++)p[i]=i;
	scanf("%d%lld",&m,&k);
	for(int i=1;i<=m;i++)scanf("%d",&a[i]);
	for(int i=m;i;i--)std::swap(p[a[i]],p[a[i]+1]);
	static int t[MX];for(int i=1;i<=n;i++)t[i]=i;
	while(k){
		static int P[MX];
		if(k&1){for(int i=1;i<=n;i++)P[i]=p[t[i]];memcpy(t+1,P+1,sizeof(int)*n);}
		for(int i=1;i<=n;i++)P[i]=p[p[i]];memcpy(p+1,P+1,sizeof(int)*n);
		k>>=1;
	}
	for(int i=1;i<=n;i++)ans[t[i]]+=x[i]-x[i-1];
	for(int i=1;i<=n;i++)ans[i]+=ans[i-1];
	for(int i=1;i<=n;i++)printf("%lld\n",ans[i]);
	return 0;
}

Submission Info

Submission Time
Task A - Prefix and Suffix
User CommonAnts
Language C++14 (GCC 5.4.1)
Score 0
Code Size 792 Byte
Status WA
Exec Time 1 ms
Memory 128 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:14:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
                ^
./Main.cpp:15:40: 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("%d",&x[i]);
                                        ^
./Main.cpp:17: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:18:40: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  for(int i=1;i<=m;i++)scanf("%d",&a[i]);
                                        ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 200
Status
WA × 3
WA × 9
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 1 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