1425F - Flamingoes of Mystery - CodeForces Solution


interactive *1400

Please click on ads to support us..

C++ Code:

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
#define fi first
#define se second
#define LSOne(S) ((S) (-S))

void solve() {
	int n;
	
	scanf("%d", &n);
	ll tot, s = 0, x;
	vll a(n+1);
	printf("? 1 %d\n", n);
	fflush(stdout);
	scanf("%lld", &tot);
	for(int i = 2; i < n; i++) {
		printf("? %d %d\n", i, n);
		fflush(stdout);
		scanf("%lld", &x);
		a[i-1] = tot - x - s;
		s += a[i-1];
	}
	ll xd;
	printf("? %d %d\n", 1, n-1);
	fflush(stdout);
	scanf("%lld", &xd);
	a[n] = tot - xd;
	a[n-1] = tot - s - a[n];
	printf("! ");
	for(int i = 1; i <= n; i++) {
		printf("%lld ", a[i]);
	}
	printf("\n");
}

int main() {
	//ios::sync_with_stdio(0); cin.tie(0);
	int T = 1;
	
	//cin >> T;
	while(T--) {
		solve();
	}
	return 0;
}


Comments

Submit
0 Comments
More Questions

1323B - Count Subrectangles
991C - Candies
1463A - Dungeon
1671D - Insert a Progression
1671A - String Building
1671B - Consecutive Points Segment
1671C - Dolce Vita
1669G - Fall Down
4D - Mysterious Present
1316B - String Modification
1204A - BowWow and the Timetable
508B - Anton and currency you all know
1672A - Log Chopping
300A - Array
48D - Permutations
677C - Vanya and Label
1583B - Omkar and Heavenly Tree
1703C - Cypher
1511C - Yet Another Card Deck
1698A - XOR Mixup
1702E - Split Into Two Sets
1703B - ICPC Balloons
1702F - Equate Multisets
1700A - Optimal Path
665C - Simple Strings
1708A - Difference Operations
1703E - Mirror Grid
1042A - Benches
1676B - Equal Candies
1705B - Mark the Dust Sweeper