-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCONFLIP.cpp
51 lines (48 loc) · 1.03 KB
/
CONFLIP.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
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define l long
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define ld long double
#define mp make_pair
#define pii pair<int,int>
#define mod 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
int main()
{
ll t;
cin>>t;
while(t--)
{
ll g;
cin>>g;
while(g--)
{
ll i1,n,q;
cin>>i1>>n>>q;
ll h,t;
if(n%2==0)
h=t=n/2;
else
if(i1==1)
{
h=(n-1)/2;
t=(n+1)/2;
}
else
{
t=(n-1)/2;
h=(n+1)/2;
}
if(q==1) cout<<h<<endl;
else cout<<t<<endl;
}
}
}