-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathA_Elections.cpp
268 lines (190 loc) · 9.11 KB
/
A_Elections.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
#include <bits/stdc++.h>
using namespace std;
// Debugg
// #define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
// void err(istream_iterator<string> it) {}
// template<typename T, typename... Args>
// void err(istream_iterator<string> it, T a, Args... args) { cerr << *it << " = " << a << endl; err(++it, args...);}
// < ---- DATA-TYPE --->
#define int long long
#define ar array
#define ll long long
#define str string
#define II int,int
#define CI char,int
// < ---- vectors ---- >
#define vi vector<int>
#define vii vector<pair<int,int>>
#define vvi vector<vector<int>>
#define VS vector<string>
#define pii pair<int, int>
// <---- maps ---- >
#define UM unordered_map
#define MII map<int,int>
#define MCI map<char,int>
#define MIV map<int,vector<int>>
// < ---- set ---- >
#define US unordered_set
#define MS multiset
#define SI set<int>
#define SC set<char>
#define SS set<string>
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define sz(container) container.size()
// < -- L - O - O - P - S -- >
#define f(x,v) for(auto &x:v)
#define fl(a,b) for (ll i = a; i <= (ll)b; i++)
#define cfl(a,b,i) for (ll i = a; i <= (ll)b; i++)
#define fo(i,n) for(ll i = 0LL ; i < (ll)n ; i++)
#define rfo(i,n) for(ll i = (ll)(n-1) ; i >= 0LL ; i--)
#define ff(n) fo(i,n)
#define rff(n) for(ll i = (ll)(n-1) ; i >= 0LL ; i--)
#define FOR(n) ff(n)
#define RFOR(n) for(ll i = (ll)(n-1) ; i >= 0LL ; i--)
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define PI 3.1415926535897932384626
const int MAX_N = 1e5 + 1;
const ll MOD = 1e9 + 7;
const ll INF = 1e9;
const ll INFLL = numeric_limits<long long>::max();
#define F first
#define S second
#define t_case int t {} ; cin >> t ; while(t--)
#define FAST ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define all(x) (x).begin() , (x).end()
#define allr(a) (a).rbegin(),(a).rend()
// < ----- TOOLS ----- >
#define st(v) sort(all(v)) ;
#define strev(c) sort(all(c)); reverse(all(c))
#define SZ(c) (int)(c).size()
#define sum(x) accumulate(all(x),0LL)
#define MIN(v) *min_element(all(v))
#define MAX(v) *max_element(all(v))
#define index(x,v) find(all(v),x) - v.begin()
// * Only use logN when elemet is surely presernt
#define indexLogN(x,container) lower_bound(all(container),x) - v.begin() ;
#define take_vector(size,vector_name,type) vector<type> vector_name(size) ; fl(0LL,size-1){ cin >> vector_name[i] ;}
#define tv(size,vector_name,type) vector<type> vector_name(size) ; fl(0LL,size-1){ cin >> vector_name[i] ;}
#define take_set(from,set_name,type) set<type> set_name; for(auto &x:from){ set_name.insert(x);}
#define frequency_maper(from,map_name,type) map<type,ll> map_name ; f(x,from){ map_name[x]++ ;}
#define hash_alpha_Lower(string_name,hash_name) vi hash_name(27,0) ;f(x,string_name) { hash_name[(x-'a'+1)]++; }
#define hash_alpha_Upper(string_name,hash_name) vi hash_name(27,0) ;f(x,string_name) { hash_name[(x-'A'+1)]++; }
// #define pi std::numbers::pi
#define bit bitset<64>
// <----- Print ----- >
#define ln cout << "\n-----------------------------------\n" ;
#define nl cout << "\n" ;
// #define print(x) for(auto &val : x){ cout << val << " " ;} cout << "\n" ;
#define print_map(map_name) f(elements,map_name){ cout << elements.first << " --> " << elements.second <<"\n" ; } cout << "\n" ;
#define print_2D(vector_name) f(x,vector_name){ f(y,x){ cout << y << " " ;} cout << "\n" ;}
// find if a given value is present in a container. Container version. Runs in log(n) for set and map
#define present(container,key) ((container).find(key) != (container).end())
//find version works for all containers. This is present in std namespace.
#define cpresent(container,key) (find(all(container),key) != (container).end())
// <--- M - A - T - H - S --->
bool isprime(ll n){for(ll i=2;i*i<=n;++i){if(n%i==0){return false;}}return true;}
ll factorial(ll n){return (n==1 || n==0) ? 1:n*factorial(n-1);}
ll power_Mod(ll a, ll b){ll res=1;while(b>0){if(b&1){res=(res*a)%MOD;}a=(a*a)%MOD;b =b>>1;}return (res)%MOD;}
ll power(ll a, ll b){ll res=1;while(b>0){if(b&1){res=(res*a);}a=(a*a);b =b>>1;}return (res);}
bool ispow2(int i) { return i && (i & -i) == i; }
ll digitsum(ll n){ll ret=0;while(n){ret+=n%10;n/=10;}return ret;}
// <----- Read / Write ---->
void read () { }
template <typename T, typename... Args>
void read (T& t, Args&... args) { cin >> t; read(args...);}
void write () { }
template <typename T, typename... Args>
void write (T& t, Args&... args) { cout << t << " "; write(args...);}
void write_error () { }
template <typename T, typename... Args>
void write_error (T& t, Args&... args) { cerr << t << " "; write_error(args...);}
#define RD read
#define WR write
#define WRE write_error
template <typename T>
void prt(T& t){ cout << t << " "<< endl;}
template <typename T , typename U>
void prt(pair<T,U> &p){ cout << "(" << p.F << "," << p.S << ") " ;}
template <typename T>
void prt(vector<T> v) {cout << "[" ; for(auto x:v){ cout << x << " ";} cout << "]" ;nl } ;
void prt(vii v) {cout << "[" ; for(auto x:v){cout << "[" <<x.F << " " << x.S << "] "; } cout << "]" ;nl } ;
void prt(vvi v) {cout << "\n" ; for(auto x:v){ cout << "[" ; for(auto y:x){ cout << y << " " ; }cout << "]" ; nl;} cout << "\n" ;} ;
template <typename T>
void prt(vector<set<T>> v) { for(auto x:v){cout << "[ " ; for(auto y:x){ cout << y << " ";} cout << "]\n"; };}
template <typename T, typename U>
void prt(map<T,U> &m){nl for(auto x:m){cout << x.F << " ---> " << x.S << "\n"; } nl } ;
template <typename T>
void prt(set<T> &s) {nl for(auto x:s){ prt(x) ; cout << " "; } nl ;} ;
// template <typename T>
// void prt(set<T> &s) {nl f(x,s){ cout << (x) << " "; } nl ;} ;
template <typename T>
void prt(stack<T> s){ while(!s.empty()){ cout << s.top() << " " ; s.pop();};}
template <typename U>
void ptr(queue<U> q){ while(!q.empty()){ cout << q.front() << " " ; q.pop();};}
/* -------------------------------ERROR STR----------------------------------- */
// template <typename T>
// void prte(T t);
template <typename T>
void prte(T t){ cerr << t << " "<< endl;}
template <typename T , typename U>
void prte(pair<T,U> &p){ cerr << "(" << p.F << "," << p.S << ") " ;}
template <typename T>
void prte(vector<T> v) { cerr << "[ " ; for(auto x:v){cerr << x << " ";} cerr<<" ] \n" ; } ;
void prte(vii v) { cerr << "[ " ; for(auto x:v){cerr << "[ " <<x.F << " " << x.S << " ] "; } cerr<<" ] \n" ; } ;
void prte(vvi v) {cerr<<"\n"; for(auto x:v){ cerr<<"[ " ; for(auto y:x){ cerr << y << " " ; } WRE(" ]"); cerr<<"\n" ;} cerr<<"\n" ;} ;
template <typename T, typename U>
void prte(map<T,U> m){ cerr << "MAP :::\n" ; for(auto x:m){cerr << x.F << " ---> " << x.S << "\n"; }cerr << "\n" ; } ;
template <typename T>
void prte(set<T> s) {cerr << "[ " ; for(auto x:s){ cerr << (x) << " "; } cerr << " ]" ; cerr<<"\n" ;} ;
template <typename T>
void prte(stack<T> s){ cerr << "[ " ; while(!s.empty()){ cerr<< s.top() << " " ; s.pop();} cerr <<"]\n";}
template <typename U>
void ptre(queue<U> q){cerr << "[ " ; while(!q.empty()){ cerr << q.front() << " " ; q.pop();};cerr <<"]\n";}
// ____________ MASTER PRINT________________________//
// Print Supported --> Maps , Sets , Vector , Vector of Vector , Vector of pair , All premitive data types
// !!!!!! Queue not supported yet , use ptre , ptr for Queue...
void mprt () { }
template <typename T, typename... Args>
void mprt (T& t, Args&... args) { prt(t) ; mprt(args...);}
// #define print(x) for(auto &val : x){ prt(val) ;} cout << "\n" ;
#define print(x) prt(x) ;
/*__________________ MASTER ERROR _____________________ */
// !!!!!! queue not supported yet , use ptre , ptr for quee ...
void mprte () { }
template <typename T, typename... Args>
void mprte (T& t, Args&... args) { prte(t) ; mprte(args...);}
/* -------------------------------------------------------------------------- */
/* SUPER DEBUG */
/* -------------------------------------------------------------------------- */
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) { cerr << *it << " = " ; mprte(a) ; ; err(++it, args...);}
#define dbg error
// <------ Sol starts --->
signed main()
{
FAST
t_case
{
int a , b , c ; cin >> a >> b >> c;
int m = max({a,b,c}) + 1;
int mx = max({a,b,c}) ;
int fr = 0 ;
if(a==mx){fr++ ; } if(b==mx){fr++ ;} ; if(c==mx){fr++ ;}
// cout << m - a << " " << m-b << " " << m-c << endl ;
if(fr==1){
cout << (a == mx ? 0 : m-a ); cout << " " ;
cout << (b == mx ? 0 : m-b ) ; cout << " " ;
cout << (c == mx ? 0 : m-c) ; cout << " \n" ;
}
else {
cout << m - a << " " << m-b << " " << m-c << endl ;
}
}
}