QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#544622#8553. Exchanging KubicRykonyWA 24ms3808kbC++201.4kb2024-09-02 19:13:072024-09-02 19:13:07

Judging History

你现在查看的是最新测评结果

  • [2024-09-02 19:13:07]
  • 评测
  • 测评结果:WA
  • 用时:24ms
  • 内存:3808kb
  • [2024-09-02 19:13:07]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
typedef long long LL;
#define INF 1e15

struct node{
    int l;
    int r;
    LL sum;
    node(){}
    node(int _l,int _r,LL _sum){
        l=_l;
        r=_r;
        sum=_sum;
    }
};

int main()
{
    int _=1;
    cin>>_;
    while (_--){
        int n;
        cin>>n;
        vector <LL> a(n+10,0);
        for (int i=1;i<=n;i++){
            cout<<"? "<<i<<" "<<i<<'\n';
            cin>>a[i];
        }
        int l=1,tp=a[1];
        LL sum=0;
        vector <node> z;
        for (int i=1;i<=n;i++){
            if (!a[i]){
                if (tp){
                    z.push_back(node(l,i-1,sum));
                    tp=0;
                    l=i;
                }
                sum=0;
            }
            else{
				if (!tp){
					z.push_back(node(l,i-1,sum));
					tp=a[i];
					l=i;
				}
				sum+=a[i];
			}
        }
        z.push_back(node(l,n,sum));
        LL mss=0,res;
        for (int i=0;i<(int)z.size()-2;i++){
			if (!z[i].sum) continue;
			mss=max({z[i].sum,z[i+2].sum,mss});
			cout<<"? "<<z[i].l<<" "<<z[i+2].r<<'\n';
			cin>>res;
			if (res==mss) a[z[i+1].l]=-INF;
			else a[z[i+1].l]=-z[i].sum-z[i+2].sum+res;
			if (z[i+2].sum==mss) mss=res;
			if (z[i+2].sum==mss&&res>mss) z[i+2].sum=res;
		}
		cout<<"! ";
		for (int i=1;i<=n;i++) cout<<a[i]<<" ";
		cout<<'\n';
    }
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3808kb

input:

2
3
1
0
1
1
5
2
0
3
0
5
4
5

output:

? 1 1
? 2 2
? 3 3
? 1 3
! 1 -1000000000000000 1 
? 1 1
? 2 2
? 3 3
? 4 4
? 5 5
? 1 3
? 3 5
! 2 -1 3 -1000000000000000 5 

result:

ok ok (2 test cases)

Test #2:

score: 0
Accepted
time: 24ms
memory: 3640kb

input:

10000
1
718876398
1
0
1
0
1
0
1
938356223
1
857157125
1
0
1
0
1
0
1
0
1
0
1
965894497
1
0
1
626061677
1
642094813
1
107398046
1
0
1
0
1
0
1
287188651
1
0
1
345108193
1
0
1
0
1
714952783
1
0
1
325760098
1
0
1
800487422
1
322806679
1
0
1
0
1
0
1
866952779
1
741483102
1
492063609
1
0
1
833448280
1
0
1
...

output:

? 1 1
! 718876398 
? 1 1
! 0 
? 1 1
! 0 
? 1 1
! 0 
? 1 1
! 938356223 
? 1 1
! 857157125 
? 1 1
! 0 
? 1 1
! 0 
? 1 1
! 0 
? 1 1
! 0 
? 1 1
! 0 
? 1 1
! 965894497 
? 1 1
! 0 
? 1 1
! 626061677 
? 1 1
! 642094813 
? 1 1
! 107398046 
? 1 1
! 0 
? 1 1
! 0 
? 1 1
! 0 
? 1 1
! 287188651 
? 1 1
! 0 
? 1 1...

result:

ok ok (10000 test cases)

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3580kb

input:

1052
9
167536100
0
373372185
0
427949326
442758705
102715118
0
0
373372185
973423149
9
248442934
306962195
570791475
593033322
0
582850731
559429390
0
120053133
2780526396
1142280121
10
785691778
0
981032824
0
0
592503870
0
0
0
0
981032824
1112480382
10
0
737563509
985502704
427600980
0
805973591
77...

output:

? 1 1
? 2 2
? 3 3
? 4 4
? 5 5
? 6 6
? 7 7
? 8 8
? 9 9
? 1 3
? 3 7
! 167536100 -1000000000000000 373372185 -1000000000000000 427949326 442758705 102715118 0 0 
? 1 1
? 2 2
? 3 3
? 4 4
? 5 5
? 6 6
? 7 7
? 8 8
? 9 9
? 1 7
? 6 9
! 248442934 306962195 570791475 593033322 -80983651 582850731 559429390 -12...

result:

wrong answer mss of [1, 8] is incorrect, expected=2181765745, found=1670744515 (test case 5)