QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#830317#9920. Money Game 2CQXYM#WA 13ms3984kbC++231.5kb2024-12-24 18:16:102024-12-24 18:16:11

Judging History

This is the latest submission verdict.

  • [2024-12-31 22:17:02]
  • hack成功,自动添加数据
  • (/hack/1322)
  • [2024-12-31 21:57:13]
  • hack成功,自动添加数据
  • (/hack/1321)
  • [2024-12-24 18:16:11]
  • Judged
  • Verdict: WA
  • Time: 13ms
  • Memory: 3984kb
  • [2024-12-24 18:16:10]
  • Submitted

answer

#pragma GCC optimize("Ofast,inline,unroll-loops")
#include<bits/stdc++.h>
void debug_(const auto&...a){
	((std::cerr<<a<<' '),...)<<'\n';
}
#define debug(A...) debug_(__LINE__,':',#A,'=',A)
using ll=long long;
#define all(s) std::begin(s),std::end(s)
using namespace std;
template<typename T>using V=std::vector<T>;
#define eb emplace_back
#define pb push_back
std::mt19937 rng(1926);
auto rnd(auto a,auto b){return std::uniform_int_distribution(a,b)(rng);}
constexpr int N=500500;
int f[N*3];
bool ckmin(auto&a,auto b){return b<a?(a=b,1):0;}
bool ckmax(auto&a,auto b){return a<b?(a=b,1):0;}
signed main(){
	cin.tie(0)->sync_with_stdio(0);
	int T;
	cin>>T;
	while(T--){
		int n;
		cin>>n;
		V<int>a(n),ans(n);
		for(auto&x:a)cin>>x;
		if(n==1){
			printf("%d\n",a[0]);
			continue;
		}
		for(int i=0;i<n;++i)a.eb(a[i]);
		for(int i=0;i<n;++i)a.eb(a[i]);
		for(int _=900;_--;){
			int pos=rnd(0,n-1)+n;
			f[pos]=a[pos]>>1;
			f[pos-1]=a[pos-1]>>1;
			for(int i=1;i<=n;++i){
				f[pos+i]=(f[pos+i-1]+a[pos+i])>>1;
				if(i>1)f[pos-i]=(f[pos-i+1]+a[pos-i])>>1;
			}
			for(int i=0;i<n;++i){
				int tmp=0;
				if(i>pos-n){
					tmp+=f[i+n-1];
				}else if(i!=pos-n){
					tmp+=f[i+2*n-1];
				}
				if(i>=pos-n){
					tmp+=f[i+1];
				}else if(i!=(pos-1)%n){
					tmp+=f[i+n+1];
				}
				ckmax(ans[i],tmp);
				// ckmax(ans[i],(i>pos?f[i+n-1]:f[i+2*n-1])+(i<pos?f[i+n+1]:f[i+1]));
			}
		}
		for(int i=0;i<n;++i){
			printf("%d ",ans[i]+a[i]);
		}
		puts("");
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3752kb

input:

3
5
2 1 4 3 5
5
2 1 3 1 2
1
1000000000

output:

6 5 7 8 8 
4 4 5 4 4 
1000000000

result:

ok 11 numbers

Test #2:

score: 0
Accepted
time: 0ms
memory: 3984kb

input:

1
10
8 15 18 15 13 4 14 4 17 5

output:

30 37 41 39 34 27 29 26 31 27 

result:

ok 10 numbers

Test #3:

score: -100
Wrong Answer
time: 13ms
memory: 3744kb

input:

1000
4
8 9 7 9
1
9
1
10
2
3 9
3
4 3 2
4
0 4 3 1
4
10 8 4 6
1
9
1
4
4
10 10 1 6
1
9
1
0
2
4 6
4
8 1 6 7
2
5 10
4
9 2 1 4
3
5 5 9
3
9 8 9
4
4 8 5 6
2
10 1
1
7
3
9 2 4
4
2 4 1 2
3
5 2 1
1
4
3
2 0 9
4
7 3 10 1
3
4 1 2
2
6 4
1
2
3
3 1 5
3
5 8 4
2
9 3
4
5 9 10 3
4
6 5 4 0
1
6
4
3 1 10 1
4
1 9 5 7
4
8 1 6 ...

output:

18 18 17 19 
9
10
7 11 
6 6 6 
3 5 5 3 
18 16 13 16 
9
4
18 17 11 15 
9
0
7 10 
13 9 11 15 
10 14 
12 7 6 10 
11 11 14 
17 16 19 
12 14 13 13 
10 11 
7
12 8 11 
5 6 4 4 
6 4 5 
4
6 5 10 
11 11 13 10 
5 4 5 
8 10 
2
5 4 7 
11 12 11 
10 11 
13 17 16 12 
9 10 8 7 
6
6 7 11 7 
9 13 12 11 
14 10 12 17 
1...

result:

wrong answer 4th numbers differ - expected: '18', found: '19'