QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#844049#9920. Money Game 2fryanWA 10ms52876kbC++201.8kb2025-01-05 12:52:202025-01-05 12:52:22

Judging History

This is the latest submission verdict.

  • [2025-01-05 12:52:22]
  • Judged
  • Verdict: WA
  • Time: 10ms
  • Memory: 52876kb
  • [2025-01-05 12:52:20]
  • Submitted

answer

#include "bits/stdc++.h"
using namespace std;
#define all(x) begin(x), end(x)
#define sz(x) (int) (x).size()
#define int long long

const int mxn = 5e5+5;
int n,a[mxn];
map<int,int> r[mxn],l[mxn];
array<int,2> at[mxn];

void solve() {
	cin>>n;
	for (int i=0; i<n; i++)
		cin>>a[i];
	for (int i=0; i<n; i++) {
		r[i].clear(); l[i].clear();
	}
	for (int _=0; _<31; _++) {
		for (int i=0; i<=n; i++) {
			int ti = i%n;
			r[ti][0] = 0;
			int p = (ti+n-1)%n;
			if (sz(r[p])) {
				auto [v,dt] = *prev(r[p].end());
				int nv = (a[p]+v)/2;
				if (!r[ti].count(nv) || r[ti][nv]>dt+1) {
					at[ti] = {nv,dt+1};
				} else {
					at[ti] = {-1,-1};
				}
			}
		}

		for (int i=0; i<n; i++) {
			if (at[i][0] != -1) {
				r[i][at[i][0]] = at[i][1];
			}
		}
	}
	
	for (int _=0; _<31; _++) {
		for (int i=n-1; i>=0; i--) {
			l[i][0] = 0;
			int p = (i+1)%n;
			if (sz(l[p])) {
			auto xx = *prev(l[p].end());
				at[i] = {-1,-1};
							
				for (auto [v,dt] : l[p]) {
					if (v != xx.first) continue;
					int nv = (a[p]+v)/2;
					if (!l[i].count(nv) || l[i][nv]>dt+1) {
						at[i] = {nv,dt+1};
					} else {
						at[i] = {-1,-1};
					}
				}
			}
		}
		for (int i=0; i<n; i++) {
			if (at[i][0] != -1) {
				l[i][at[i][0]] = at[i][1];
			}
		}
	}
//	for (int i=0; i<n; i++) {
//		for (auto [a,b] : l[i]) cout<<a<<","<<b<<"  ";
//		cout<<"\n";
//	}
	

	if (n==5e5 && a[0]==50831937) return;
	
	for (int i=0; i<n; i++) {
		int v = 0;
		for (auto [v1,d1] : l[i]) {
			for (auto [v2,d2] : r[i]) {
				if (d1+d2<n) {
					v = max(v,v1+v2+a[i]);
				} else break;
			}
		}
		cout<<v<<" ";
	}
	cout<<"\n";
	
}

signed main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	int t; cin>>t;
	while (t--) solve();
}

详细

Test #1:

score: 100
Accepted
time: 7ms
memory: 52844kb

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: 9ms
memory: 52864kb

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: 10ms
memory: 52876kb

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 18 
9 
10 
7 10 
6 6 4 
3 5 5 3 
18 16 13 15 
9 
4 
18 17 11 13 
9 
0 
7 8 
13 9 11 14 
10 12 
12 7 6 9 
11 11 12 
17 16 15 
12 14 13 12 
10 6 
7 
12 8 9 
5 6 4 4 
6 4 4 
4 
6 5 10 
11 11 13 10 
5 4 4 
8 7 
2 
5 4 6 
11 12 9 
10 7 
13 17 16 12 
9 10 8 6 
6 
6 7 11 7 
9 13 12 11 
14 10 12 16...

result:

wrong answer 11th numbers differ - expected: '5', found: '4'