Skip to content

Commit a34cc28

Browse files
committed
cf round
1 parent a1c2292 commit a34cc28

18 files changed

+2296
-1
lines changed

Codechef/DARLIG.cpp

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
/*
2+
written by Pankaj Kumar.
3+
country:-INDIA
4+
*/
5+
#include <bits/stdc++.h>
6+
#include <ext/pb_ds/assoc_container.hpp>
7+
#include <ext/pb_ds/tree_policy.hpp>
8+
using namespace std;
9+
using namespace __gnu_pbds;
10+
typedef long long ll ;
11+
typedef vector<ll> vl;
12+
typedef vector<vector<ll>> vvl;
13+
#define speed cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
14+
/* Abbrevations */
15+
#define ff first
16+
#define ss second
17+
#define mp make_pair
18+
#define line cout<<endl;
19+
#define pb push_back
20+
// Some print
21+
#define no cout<<"NO"<<endl;
22+
#define yes cout<<"YES"<<endl;
23+
// sort
24+
#define all(V) (V).begin(),(V).end()
25+
#define srt(V) sort(all(V))
26+
#define srtGreat(V) sort(all(V),greater<ll>())
27+
// some extra
28+
#define printv(v) for(ll i=0;i<ll(v.size());i++){cout<<v[i]<<" ";} line;
29+
#define precision(x) cout<<fixed<<setprecision(x);
30+
#define sz(V) ll(V.size())
31+
// datatype definination
32+
#define ordered_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
33+
34+
35+
class Codeforces{
36+
private:
37+
// read only variable
38+
const ll INF=1e18;
39+
const ll mod1=1e9+7;
40+
const ll mod2=998244353;
41+
42+
43+
public:
44+
Codeforces(){
45+
46+
}
47+
48+
ll power(ll x,ll y){
49+
ll result=1;
50+
while(y>0){
51+
if(y&1){
52+
result*=x;
53+
}
54+
y>>=1;
55+
x*=x;
56+
}
57+
return result;
58+
}
59+
60+
ll power(ll x,ll y,ll mod){
61+
ll result=1;
62+
x%=mod;
63+
while(y>0){
64+
if(y&1){
65+
result*=x;
66+
result%=mod;
67+
}
68+
y>>=1;
69+
x*=x;
70+
x%=mod;
71+
}
72+
return result;
73+
}
74+
75+
ll str_to_num(string s){
76+
stringstream pk(s);
77+
ll num;
78+
pk>>num;
79+
return num;
80+
}
81+
82+
string num_to_str(ll num){
83+
return to_string(num);
84+
}
85+
// Techniques :
86+
// divide into cases, brute force, pattern finding
87+
// sort, greedy, binary search, two pointer
88+
// transform into graph
89+
90+
// Experience :
91+
// Cp is nothing but only observation and mathematics.
92+
93+
ll solve(){
94+
ll n,k;
95+
cin>>n>>k;
96+
n=n%4;
97+
if(n==0){
98+
n=4;
99+
}
100+
if(n<=3){
101+
if(k==1){
102+
cout<<"Ambiguous"<<endl;
103+
}
104+
else{
105+
cout<<"On"<<endl;
106+
}
107+
}
108+
else{
109+
if(k==1){
110+
cout<<"On"<<endl;
111+
}
112+
else{
113+
cout<<"Off"<<endl;
114+
}
115+
}
116+
117+
return 0;
118+
}
119+
};
120+
121+
122+
/* --------------------MAIN PROGRAM----------------------------*/
123+
124+
int main()
125+
{
126+
speed;
127+
/* #ifndef ONLINE_JUDGE
128+
freopen("input.txt","r",stdin);
129+
freopen("output.txt","w",stdout);
130+
#endif */
131+
ll TestCase=1;
132+
cin>>TestCase;
133+
while(TestCase--){
134+
Codeforces cf;
135+
cf.solve();
136+
}
137+
}
138+
/* -----------------END OF PROGRAM --------------------*/
139+
/*
140+
* stuff you should look before submission
141+
* constraint and time limit
142+
* int overflow
143+
* special test case (n=0||n=1||n=2)
144+
* don't get stuck on one approach if you get wrong answer
145+
*/
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
/*
2+
written by Pankaj Kumar.
3+
country:-INDIA
4+
*/
5+
#include <bits/stdc++.h>
6+
#include <ext/pb_ds/assoc_container.hpp>
7+
#include <ext/pb_ds/tree_policy.hpp>
8+
using namespace std;
9+
using namespace __gnu_pbds;
10+
typedef long long ll ;
11+
typedef vector<ll> vl;
12+
typedef vector<vector<ll>> vvl;
13+
#define speed cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
14+
/* Abbrevations */
15+
#define ff first
16+
#define ss second
17+
#define mp make_pair
18+
#define line cout<<endl;
19+
#define pb push_back
20+
// Some print
21+
#define no cout<<"NO"<<endl;
22+
#define yes cout<<"YES"<<endl;
23+
// sort
24+
#define all(V) (V).begin(),(V).end()
25+
#define srt(V) sort(all(V))
26+
#define srtGreat(V) sort(all(V),greater<ll>())
27+
// some extra
28+
#define printv(v) for(ll i=0;i<ll(v.size());i++){cout<<v[i]<<" ";} line;
29+
#define precision(x) cout<<fixed<<setprecision(x);
30+
#define sz(V) ll(V.size())
31+
// datatype definination
32+
#define ordered_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
33+
34+
35+
class Codeforces{
36+
private:
37+
// read only variable
38+
const ll INF=1e18;
39+
const ll mod1=1e9+7;
40+
const ll mod2=998244353;
41+
42+
43+
public:
44+
Codeforces(){
45+
46+
}
47+
48+
ll power(ll x,ll y){
49+
ll result=1;
50+
while(y>0){
51+
if(y&1){
52+
result*=x;
53+
}
54+
y>>=1;
55+
x*=x;
56+
}
57+
return result;
58+
}
59+
60+
ll power(ll x,ll y,ll mod){
61+
ll result=1;
62+
x%=mod;
63+
while(y>0){
64+
if(y&1){
65+
result*=x;
66+
result%=mod;
67+
}
68+
y>>=1;
69+
x*=x;
70+
x%=mod;
71+
}
72+
return result;
73+
}
74+
75+
ll str_to_num(string s){
76+
stringstream pk(s);
77+
ll num;
78+
pk>>num;
79+
return num;
80+
}
81+
82+
string num_to_str(ll num){
83+
return to_string(num);
84+
}
85+
// Techniques :
86+
// divide into cases, brute force, pattern finding
87+
// sort, greedy, binary search, two pointer
88+
// transform into graph
89+
90+
// Experience :
91+
// Cp is nothing but only observation and mathematics.
92+
ll solve(){
93+
ll a,b;
94+
cin>>a>>b;
95+
ll mini=min(a,b);
96+
ll maxo=max(a,b);
97+
if(mini==1){
98+
if(maxo<=2){
99+
if(maxo==1){
100+
cout<<0<<endl;
101+
}
102+
else{
103+
cout<<1<<endl;
104+
}
105+
}
106+
else{
107+
cout<<-1<<endl;
108+
return 0;
109+
}
110+
return 0;
111+
}
112+
else{
113+
ll ans=0;
114+
ans+=(mini-1)*2;
115+
// cout<<"ans is "<<ans<<endl;
116+
maxo-=mini;
117+
if(maxo&1){
118+
ans+=(maxo/2)*4;
119+
ans++;
120+
}
121+
else{
122+
ans+=(maxo/2)*4;
123+
}
124+
cout<<ans<<endl;
125+
}
126+
return 0;
127+
}
128+
};
129+
130+
131+
/* --------------------MAIN PROGRAM----------------------------*/
132+
133+
int main()
134+
{
135+
speed;
136+
/* #ifndef ONLINE_JUDGE
137+
freopen("input.txt","r",stdin);
138+
freopen("output.txt","w",stdout);
139+
#endif */
140+
ll TestCase=1;
141+
cin>>TestCase;
142+
while(TestCase--){
143+
Codeforces cf;
144+
cf.solve();
145+
}
146+
}
147+
/* -----------------END OF PROGRAM --------------------*/
148+
/*
149+
* stuff you should look before submission
150+
* constraint and time limit
151+
* int overflow
152+
* special test case (n=0||n=1||n=2)
153+
* don't get stuck on one approach if you get wrong answer
154+
*/

0 commit comments

Comments
 (0)