Skip to content

Commit d0a9fe7

Browse files
committed
p
1 parent c102de8 commit d0a9fe7

10 files changed

Lines changed: 527 additions & 99 deletions
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"name":"A. Ian Visits Mary","group":"Codeforces - Codeforces Round 865 (Div. 2)","url":"https://codeforces.com/contest/1816/problem/A","interactive":false,"memoryLimit":256,"timeLimit":1000,"tests":[{"id":1681319004506,"input":"8\n3 4\n4 4\n3 6\n2 2\n1 1\n7 3\n2022 2023\n1000000000 1000000000","output":"1\n3 4\n2\n3 2\n4 4\n2\n5 3\n3 6\n2\n1 0\n2 2\n1\n1 1\n1\n7 3\n1\n2022 2023\n2\n69420420 469696969\n1000000000 1000000000"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"AIanVisitsMary"}},"batch":{"id":"7507c06e-4a4d-4a9b-b2ae-0ac258d2aecf","size":1},"srcPath":"c:\\Users\\prakh\\Desktop\\projects\\2023\\Competitive_programming_\\A_Ian_Visits_Mary.cpp"}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"name":"B. Grid Reconstruction","group":"Codeforces - Codeforces Round 865 (Div. 2)","url":"https://codeforces.com/contest/1816/problem/B","interactive":false,"memoryLimit":256,"timeLimit":1000,"tests":[{"id":1681323571187,"input":"3\n2\n4\n6","output":"3 2\n1 4\n8 2 6 4\n1 5 3 7\n11 5 9 1 7 3\n6 10 2 8 4 12"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"BGridReconstruction"}},"batch":{"id":"df090143-69a4-402e-b9fe-2f42499b81a5","size":1},"srcPath":"c:\\Users\\prakh\\Desktop\\projects\\2023\\Competitive_programming_\\B_Grid_Reconstruction.cpp"}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"name":"C. Constructive Problem","group":"Codeforces - Codeforces Round 866 (Div. 2)","url":"https://codeforces.com/contest/1820/problem/C","interactive":false,"memoryLimit":256,"timeLimit":1000,"tests":[{"id":1681757455705,"input":"4\n3\n1 2 1\n4\n0 2 2 0\n4\n3 2 0 2\n1\n0","output":"Yes\nYes\nNo\nNo"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"CConstructiveProblem"}},"batch":{"id":"d6b4aa54-bc8d-4282-959e-1b32f158e74b","size":1},"srcPath":"c:\\Users\\prakh\\Desktop\\projects\\2023\\Competitive_programming_\\C_Constructive_Problem.cpp"}

‎A_Ian_Visits_Mary.cpp‎

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
2+
#include <bits/stdc++.h>
3+
#include <unordered_set>
4+
#include <chrono>
5+
#define ll long long
6+
#define int long long
7+
#define MOD1 998244353
8+
#define INF 1e18
9+
#define endl "\n"
10+
#define vi vector<int>
11+
#define pb push_back
12+
#define vvi vector<vector<int>>
13+
#define pii pair<int, int>
14+
#define ff first
15+
#define ss second
16+
#define ss second
17+
#define PI 3.141592653589793238462
18+
#define set_bits __builtin_popcountll
19+
#define sz(x) ((int)(x).size())
20+
#define all(x) (x).begin(), (x).end()
21+
#define f(i,a,b) for(ll i=a;i<b;i++)
22+
23+
#define amax(a) *max_element(a, a + n)
24+
#define amin(a) *min_element(a, a + n)
25+
#define vmax(a) *max_element(a.begin(), a.end())
26+
#define vmin(a) *min_element(a.begin(), a.end())
27+
using namespace std;
28+
#define watch(x) cout << (#x) << " = " << (x) << endl
29+
const int MOD = 1e9 + 7;
30+
ll gcd(ll a, ll b) {if (b > a) {return gcd(b, a);} if (b == 0) {return a;} return gcd(b, a % b);}
31+
ll mult(ll x, ll y) {ll res = x * y;return (res >= MOD ? res % MOD : res);}
32+
ll factorial(ll v){ll ans=1;for(int i=2;i<=v;i++){ans*=i;ans%=MOD;}return ans;}
33+
ll power(ll a, ll n){ll res = 1;while(n){if(n%2 == 1){res = (res * a)%MOD;n--;}else{a = (a * a)%MOD;n = n/2;}}return res;}
34+
vector<ll> sieve(int n) {int*arr = new int[n + 1](); vector<ll> vect; for (int i = 2; i <= n; i++)if (arr[i] == 0) {vect.push_back(i); for (int j = 2 * i; j <= n; j += i)arr[j] = 1;} return vect;}
35+
void vin( vector<int> &v , int n ){for (int i = 0; i < n; i++){int x ;cin >> x; v.push_back(x);}}
36+
void vout(vector<int> &v){for (int i = 0; i < v.size(); i++){cout << v[i] << " " ;}cout << endl;}
37+
ll highestPowerof2(ll n){ ll p = (ll)log2(n); return (ll)pow(2, p);}
38+
bool isPowerOfTwo(int n){ if(n==0) return false; return (ceil(log2(n)) == floor(log2(n)));}
39+
bool chkprime(int n){ for(int i = 2 ; i*i <= n ; i++){ if( n % i == 0) return false;} return true; }
40+
string to_binary(int n) { string s = ""; for (int i = 31; i >= 0; i--) { int k = n >> i; if (k & 1) s = s + "1";else s = s + "0";}return s ; }
41+
static void removeTrailingCharacters(std::string &str, const char charToRemove) {str.erase (str.find_last_not_of(charToRemove) + 1, std::string::npos );}
42+
static void removeLeadingCharacters(std::string &str, const char charToRemove) {str.erase(0, std::min(str.find_first_not_of(charToRemove), str.size() - 1));}
43+
long long lcm(int a, int b){ return (a / gcd(a, b)) * b;}
44+
int digits_count(int n){int d=0;while(n != 0){d++;n /=10;}return d;}
45+
vector<string> to_token(string s){vector<string> tokens; stringstream chk1(s); string tmp; while(getline(chk1, tmp, ' ')){ tokens.push_back(tmp); } return tokens;}
46+
vector<int> findFactors(int n){vector<int> v;for (int i=1; i<=sqrt(n); i++){if (n%i == 0){if (n/i == i)v.pb(i);else {v.pb(i);v.pb(n/i);}}}sort(all(v));return v;}
47+
48+
void prakhar() {
49+
50+
int a, b ;
51+
cin >> a >> b ;
52+
53+
54+
55+
if(a == 1 && b == 1){
56+
cout << 1 << endl;
57+
cout <<a << " " << b << endl;
58+
return;
59+
}
60+
if(a == -1 && b == 1){
61+
cout << 1 << endl;
62+
cout <<a << " " << b << endl;
63+
64+
return;
65+
}
66+
if(a == 1 && b == -1){
67+
cout << 1 << endl;
68+
cout <<a << " " << b << endl;
69+
70+
return;
71+
}
72+
if(a == -1 && b == -1){
73+
cout << 1 << endl;
74+
cout <<a << " " << b << endl;
75+
76+
return;
77+
}
78+
79+
if(gcd(a, b) == 1){
80+
cout << 1 << endl;
81+
cout << a << " " << b << endl;
82+
return;
83+
}
84+
85+
cout << 2 << endl;
86+
87+
cout << a - 1 << " " << 1 << endl;
88+
cout << a << " " << b << endl;
89+
return;
90+
91+
92+
if(a-1 != b + 1 && a-1 != 0 && b+1 != 0 && gcd(a-1, b+1) == 1 && a -1 <= 1000000000 && b+ 1 <= 1000000000 ){
93+
cout << a-1 << " " << b+1 << endl;
94+
95+
cout << a << " " << b << endl;
96+
return;
97+
}
98+
if(a-1 != b - 1&& a-1 != 0 && b-1 != 0 && gcd(a-1, b-1) == 1 && a-1 <= 1000000000 && b-1 <= 1000000000){
99+
cout << a-1 << " " << b-1 << endl;
100+
101+
cout << a << " " << b << endl;
102+
return;
103+
}
104+
if(a + 1 != b + 1&& a+1 != 0 && b+1 != 0 && gcd(a+1, b+1) == 1 && a+1 <= 1000000000 && b+1 <= 1000000000){
105+
cout << a+1 << " " << b+1 << endl;
106+
107+
cout << a << " " << b << endl;
108+
return;
109+
}
110+
if(a+1 != b -1 && a + 1 != 0 && b -1 != 0 && gcd(a+1, b-1) == 1 && a+1 <= 1000000000 && b-1 <= 1000000000){
111+
cout << a-1 << " " << b+1 << endl;
112+
113+
cout << a << " " << b << endl;
114+
return;
115+
}
116+
117+
int dx[] = {+1, 0, -1, 0};
118+
int dy[] = {0, + 1, 0 , -1};
119+
120+
for (int i = 0; i < 4; i++)
121+
{
122+
int x = a + dx[i];
123+
int y = b + dy[i];
124+
125+
if(x != y && x!= 0 && y != 0 && gcd(x, y) == 1 && x <= 1000000000 && y <= 1000000000){
126+
cout << x << " " << y << endl;
127+
128+
cout << a << " " << b << endl;
129+
return;
130+
}
131+
}
132+
133+
134+
135+
}
136+
137+
int32_t main() {
138+
ios_base::sync_with_stdio(false);
139+
cin.tie(NULL);
140+
#ifndef ONLINE_JUDGE
141+
freopen("input.txt", "r", stdin);
142+
freopen("output.txt", "w", stdout);
143+
freopen("error.txt", "w", stderr);
144+
#endif
145+
auto start = chrono::steady_clock::now();
146+
147+
// Insert the code that will be timed
148+
149+
150+
ll t = 1 ;
151+
cin >> t ;
152+
int ii;
153+
for ( ii = 1; ii <= t; ii++) {
154+
// cout << "Case #" << i <<": ";
155+
prakhar();
156+
}
157+
158+
auto end = chrono::steady_clock::now();
159+
160+
auto diff = end - start;
161+
cerr << chrono::duration <double, nano> (diff).count() << " ns" << endl;
162+
163+
return 0;
164+
165+
}

‎B_Grid_Reconstruction.cpp‎

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
2+
#include <bits/stdc++.h>
3+
#include <unordered_set>
4+
#include <chrono>
5+
#define ll long long
6+
#define int long long
7+
#define MOD1 998244353
8+
#define INF 1e18
9+
#define endl "\n"
10+
#define vi vector<int>
11+
#define pb push_back
12+
#define vvi vector<vector<int>>
13+
#define pii pair<int, int>
14+
#define ff first
15+
#define ss second
16+
#define ss second
17+
#define PI 3.141592653589793238462
18+
#define set_bits __builtin_popcountll
19+
#define sz(x) ((int)(x).size())
20+
#define all(x) (x).begin(), (x).end()
21+
#define f(i,a,b) for(ll i=a;i<b;i++)
22+
23+
#define amax(a) *max_element(a, a + n)
24+
#define amin(a) *min_element(a, a + n)
25+
#define vmax(a) *max_element(a.begin(), a.end())
26+
#define vmin(a) *min_element(a.begin(), a.end())
27+
using namespace std;
28+
#define watch(x) cout << (#x) << " = " << (x) << endl
29+
const int MOD = 1e9 + 7;
30+
ll gcd(ll a, ll b) {if (b > a) {return gcd(b, a);} if (b == 0) {return a;} return gcd(b, a % b);}
31+
ll mult(ll x, ll y) {ll res = x * y;return (res >= MOD ? res % MOD : res);}
32+
ll factorial(ll v){ll ans=1;for(int i=2;i<=v;i++){ans*=i;ans%=MOD;}return ans;}
33+
ll power(ll a, ll n){ll res = 1;while(n){if(n%2 == 1){res = (res * a)%MOD;n--;}else{a = (a * a)%MOD;n = n/2;}}return res;}
34+
vector<ll> sieve(int n) {int*arr = new int[n + 1](); vector<ll> vect; for (int i = 2; i <= n; i++)if (arr[i] == 0) {vect.push_back(i); for (int j = 2 * i; j <= n; j += i)arr[j] = 1;} return vect;}
35+
void vin( vector<int> &v , int n ){for (int i = 0; i < n; i++){int x ;cin >> x; v.push_back(x);}}
36+
void vout(vector<int> &v){for (int i = 0; i < v.size(); i++){cout << v[i] << " " ;}cout << endl;}
37+
ll highestPowerof2(ll n){ ll p = (ll)log2(n); return (ll)pow(2, p);}
38+
bool isPowerOfTwo(int n){ if(n==0) return false; return (ceil(log2(n)) == floor(log2(n)));}
39+
bool chkprime(int n){ for(int i = 2 ; i*i <= n ; i++){ if( n % i == 0) return false;} return true; }
40+
string to_binary(int n) { string s = ""; for (int i = 31; i >= 0; i--) { int k = n >> i; if (k & 1) s = s + "1";else s = s + "0";}return s ; }
41+
static void removeTrailingCharacters(std::string &str, const char charToRemove) {str.erase (str.find_last_not_of(charToRemove) + 1, std::string::npos );}
42+
static void removeLeadingCharacters(std::string &str, const char charToRemove) {str.erase(0, std::min(str.find_first_not_of(charToRemove), str.size() - 1));}
43+
long long lcm(int a, int b){ return (a / gcd(a, b)) * b;}
44+
int digits_count(int n){int d=0;while(n != 0){d++;n /=10;}return d;}
45+
vector<string> to_token(string s){vector<string> tokens; stringstream chk1(s); string tmp; while(getline(chk1, tmp, ' ')){ tokens.push_back(tmp); } return tokens;}
46+
vector<int> findFactors(int n){vector<int> v;for (int i=1; i<=sqrt(n); i++){if (n%i == 0){if (n/i == i)v.pb(i);else {v.pb(i);v.pb(n/i);}}}sort(all(v));return v;}
47+
48+
void prakhar() {
49+
50+
int n ;
51+
cin >> n;
52+
53+
cout << 2 * n << " ";
54+
55+
int take = (n+1) / 2;
56+
take++;
57+
58+
59+
for(int i = 0 ; i < n-1 ; i++){
60+
cout << take++ << " ";
61+
}
62+
cout << endl;
63+
64+
int i = 1;
65+
int j = 2 * n - 1;
66+
67+
for(int k = 0 ; k < n; k++){
68+
if(k % 2 == 0){
69+
cout << i++ << " ";
70+
} else {
71+
cout << j-- << " ";
72+
}
73+
}
74+
cout << endl;
75+
76+
77+
}
78+
79+
int32_t main() {
80+
ios_base::sync_with_stdio(false);
81+
cin.tie(NULL);
82+
#ifndef ONLINE_JUDGE
83+
freopen("input.txt", "r", stdin);
84+
freopen("output.txt", "w", stdout);
85+
freopen("error.txt", "w", stderr);
86+
#endif
87+
auto start = chrono::steady_clock::now();
88+
89+
// Insert the code that will be timed
90+
91+
92+
ll t = 1 ;
93+
cin >> t ;
94+
int ii;
95+
for ( ii = 1; ii <= t; ii++) {
96+
// cout << "Case #" << i <<": ";
97+
prakhar();
98+
}
99+
100+
auto end = chrono::steady_clock::now();
101+
102+
auto diff = end - start;
103+
cerr << chrono::duration <double, nano> (diff).count() << " ns" << endl;
104+
105+
return 0;
106+
107+
}

‎C_Constructive_Problem.cpp‎

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
2+
#include <bits/stdc++.h>
3+
#include <unordered_set>
4+
#include <chrono>
5+
#define ll long long
6+
#define int long long
7+
#define MOD1 998244353
8+
#define INF 1e18
9+
#define endl "\n"
10+
#define vi vector<int>
11+
#define pb push_back
12+
#define vvi vector<vector<int>>
13+
#define pii pair<int, int>
14+
#define ff first
15+
#define ss second
16+
#define ss second
17+
#define PI 3.141592653589793238462
18+
#define set_bits __builtin_popcountll
19+
#define sz(x) ((int)(x).size())
20+
#define all(x) (x).begin(), (x).end()
21+
#define f(i,a,b) for(ll i=a;i<b;i++)
22+
23+
#define amax(a) *max_element(a, a + n)
24+
#define amin(a) *min_element(a, a + n)
25+
#define vmax(a) *max_element(a.begin(), a.end())
26+
#define vmin(a) *min_element(a.begin(), a.end())
27+
using namespace std;
28+
#define watch(x) cout << (#x) << " = " << (x) << endl
29+
const int MOD = 1e9 + 7;
30+
ll gcd(ll a, ll b) {if (b > a) {return gcd(b, a);} if (b == 0) {return a;} return gcd(b, a % b);}
31+
ll mult(ll x, ll y) {ll res = x * y;return (res >= MOD ? res % MOD : res);}
32+
ll factorial(ll v){ll ans=1;for(int i=2;i<=v;i++){ans*=i;ans%=MOD;}return ans;}
33+
ll power(ll a, ll n){ll res = 1;while(n){if(n%2 == 1){res = (res * a)%MOD;n--;}else{a = (a * a)%MOD;n = n/2;}}return res;}
34+
vector<ll> sieve(int n) {int*arr = new int[n + 1](); vector<ll> vect; for (int i = 2; i <= n; i++)if (arr[i] == 0) {vect.push_back(i); for (int j = 2 * i; j <= n; j += i)arr[j] = 1;} return vect;}
35+
void vin( vector<int> &v , int n ){for (int i = 0; i < n; i++){int x ;cin >> x; v.push_back(x);}}
36+
void vout(vector<int> &v){for (int i = 0; i < v.size(); i++){cout << v[i] << " " ;}cout << endl;}
37+
ll highestPowerof2(ll n){ ll p = (ll)log2(n); return (ll)pow(2, p);}
38+
bool isPowerOfTwo(int n){ if(n==0) return false; return (ceil(log2(n)) == floor(log2(n)));}
39+
bool chkprime(int n){ for(int i = 2 ; i*i <= n ; i++){ if( n % i == 0) return false;} return true; }
40+
string to_binary(int n) { string s = ""; for (int i = 31; i >= 0; i--) { int k = n >> i; if (k & 1) s = s + "1";else s = s + "0";}return s ; }
41+
static void removeTrailingCharacters(std::string &str, const char charToRemove) {str.erase (str.find_last_not_of(charToRemove) + 1, std::string::npos );}
42+
static void removeLeadingCharacters(std::string &str, const char charToRemove) {str.erase(0, std::min(str.find_first_not_of(charToRemove), str.size() - 1));}
43+
long long lcm(int a, int b){ return (a / gcd(a, b)) * b;}
44+
int digits_count(int n){int d=0;while(n != 0){d++;n /=10;}return d;}
45+
vector<string> to_token(string s){vector<string> tokens; stringstream chk1(s); string tmp; while(getline(chk1, tmp, ' ')){ tokens.push_back(tmp); } return tokens;}
46+
vector<int> findFactors(int n){vector<int> v;for (int i=1; i<=sqrt(n); i++){if (n%i == 0){if (n/i == i)v.pb(i);else {v.pb(i);v.pb(n/i);}}}sort(all(v));return v;}
47+
48+
//SPEED IS NOT THE CRITERIA, CODE SHOULD BE A NO BRAINER, CMP KILLS, MOCIM
49+
50+
void prakhar() {
51+
52+
53+
}
54+
55+
int32_t main() {
56+
ios_base::sync_with_stdio(false);
57+
cin.tie(NULL);
58+
#ifndef ONLINE_JUDGE
59+
freopen("input.txt", "r", stdin);
60+
freopen("output.txt", "w", stdout);
61+
freopen("error.txt", "w", stderr);
62+
#endif
63+
auto start = chrono::steady_clock::now();
64+
65+
// Insert the code that will be timed
66+
67+
68+
ll t = 1 ;
69+
cin >> t ;
70+
int ii;
71+
for ( ii = 1; ii <= t; ii++) {
72+
// cout << "Case #" << i <<": ";
73+
prakhar();
74+
}
75+
76+
auto end = chrono::steady_clock::now();
77+
78+
auto diff = end - start;
79+
cerr << chrono::duration <double, nano> (diff).count() << " ns" << endl;
80+
81+
return 0;
82+
83+
}

0 commit comments

Comments
 (0)