Submission #60283350


Source Code Expand

#include<bits/stdc++.h>
#include"atcoder/all"
using namespace std;
using namespace atcoder;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) a.begin(),a.end()
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> P;
const ll mod=998244353;
const ll inf=1ll<<61;
typedef modint998244353 mi;

struct S{
	ll sum=0;
	int len=1;
	int valid=0;
};

S op(S x,S y){
	if(y.len%2){
		return {-x.sum+y.sum,x.len+y.len,x.valid&y.valid};
	}
	else{
		return {x.sum+y.sum,x.len+y.len,x.valid&y.valid};
	}

}

S e(){
	return {0,0,1};
}

int main(){
	int n,q;cin>>n>>q;
	vector<S>init;
	rep(i,n)init.push_back({0,1,0});
	segtree<S,op,e>seg(init);

	rep(i,q){
		ll t,x,y,v;
		cin>>t>>x>>y>>v;
		x--;y--;
		if(t==0){
			seg.set(x,{v,1,1});
		}
		else{
			if(x==y){
				cout<<v<<endl;
			}
			else{
				S interval=seg.prod(min(x,y),max(x,y));
				if(interval.valid){
					if(interval.len%2)cout<<interval.sum-v<<endl;
					else if(x<y)cout<<v+interval.sum<<endl;
					else cout<<v-interval.sum<<endl;
				}
				else{
					cout<<"Ambiguous"<<endl;
				}
			}
		}
	}
}

Submission Info

Submission Time
Task 068 - Paired Information(★5)
User Rho17
Language C++ 20 (gcc 12.2)
Score 5
Code Size 1125 Byte
Status AC
Exec Time 129 ms
Memory 9096 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 5 / 5
Status
AC × 2
AC × 13
Set Name Test Cases
Sample 00_sample_0.txt, 00_sample_1.txt
All 00_sample_0.txt, 00_sample_1.txt, 01_random_0.txt, 01_random_1.txt, 01_random_2.txt, 01_random_3.txt, 01_random_4.txt, 01_random_5.txt, 01_random_6.txt, 01_random_7.txt, 02_maxima_0.txt, 02_maxima_1.txt, 02_maxima_2.txt
Case Name Status Exec Time Memory
00_sample_0.txt AC 1 ms 3712 KiB
00_sample_1.txt AC 1 ms 3524 KiB
01_random_0.txt AC 84 ms 9044 KiB
01_random_1.txt AC 106 ms 8348 KiB
01_random_2.txt AC 104 ms 8428 KiB
01_random_3.txt AC 129 ms 6072 KiB
01_random_4.txt AC 79 ms 6084 KiB
01_random_5.txt AC 76 ms 6116 KiB
01_random_6.txt AC 70 ms 8740 KiB
01_random_7.txt AC 126 ms 6116 KiB
02_maxima_0.txt AC 89 ms 9096 KiB
02_maxima_1.txt AC 90 ms 8864 KiB
02_maxima_2.txt AC 95 ms 8428 KiB