Skip to content

Commit 8f4f8b5

Browse files
committed
cf round 706
1 parent f134392 commit 8f4f8b5

15 files changed

+1799
-0
lines changed
+139
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
/*
2+
written by Pankaj Kumar.
3+
country:-INDIA
4+
Institute: National Institute of Technology, Uttarakhand
5+
*/
6+
#include <bits/stdc++.h>
7+
#include <ext/pb_ds/assoc_container.hpp>
8+
#include <ext/pb_ds/tree_policy.hpp>
9+
using namespace std;
10+
using namespace __gnu_pbds;
11+
typedef long long ll ;
12+
typedef vector<ll> vl;
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+
#define Endl "\n"
21+
// loops
22+
#define forin(arr,n) for(ll i=0;i<n;i++) cin>>arr[i];
23+
// Some print
24+
#define no cout<<"NO"<<endl;
25+
#define yes cout<<"YES"<<endl;
26+
// sort
27+
#define all(V) (V).begin(),(V).end()
28+
#define srt(V) sort(all(V))
29+
#define srtGreat(V) sort(all(V),greater<ll>())
30+
// some extra
31+
#define printv(v) for(ll i=0;i<ll(v.size());i++){cout<<v[i]<<" ";} line;
32+
#define precision(x) cout<<fixed<<setprecision(x);
33+
#define sz(V) ll(V.size())
34+
// template
35+
template <typename T>
36+
T mymax(T x,T y)
37+
{
38+
return (x>y)?x:y;
39+
}
40+
// function
41+
ll power(ll x,ll y,ll mod)
42+
{
43+
ll res=1;
44+
// x=x%mod;
45+
while(y>0)
46+
{
47+
if(y%2==1)
48+
{
49+
res*=x;
50+
// res=res%mod;
51+
}
52+
y/=2; x*=x; // x=x%mod;
53+
}
54+
return res;
55+
}
56+
ll str_to_num(string s)
57+
{
58+
return stoi(s);
59+
}
60+
61+
string num_to_str(ll num)
62+
{
63+
return to_string(num);
64+
}
65+
// datatype definination
66+
#define ordered_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
67+
class Point
68+
{
69+
public:
70+
ll x;
71+
ll y;
72+
ll z;
73+
ll getsum()
74+
{
75+
return x+y+z;
76+
}
77+
};
78+
/* ascii value
79+
A=65,Z=90,a=97,z=122
80+
*/
81+
/* --------------------MAIN PROGRAM----------------------------*/
82+
// to run ctrl+b
83+
84+
ll solve()
85+
{
86+
ll n,k;
87+
cin>>n>>k;
88+
string s="";
89+
for(ll i=1;i<=n-2;i++){
90+
s+='a';
91+
}
92+
s+="bb";
93+
// reverse(all(s));
94+
ll pos=0;
95+
for(ll i=1;i<sz(s);i++){
96+
ll sum=(i*(i+1))/2;
97+
if(sum>=k){
98+
pos=i;
99+
break;
100+
}
101+
}
102+
// cout<<"pos is "<<pos<<endl;
103+
swap(s[n-pos-1],s[n-2]);
104+
k-=(pos*(pos+1))/2;
105+
if(k<0)
106+
k=pos+k;
107+
if(k==0)
108+
k=pos-1;
109+
else
110+
k--;
111+
// cout<<"k is "<<k<<endl;
112+
swap(s[n-1-k],s[n-1]);
113+
// reverse(all(s));
114+
cout<<s<<endl;
115+
return 0;
116+
}
117+
118+
int main()
119+
{
120+
speed;
121+
/* #ifndef ONLINE_JUDGE
122+
freopen("input.txt","r",stdin);
123+
freopen("output.txt","w",stdout);
124+
#endif */
125+
ll TestCase=1;
126+
cin>>TestCase;
127+
while(TestCase--)
128+
{
129+
solve();
130+
}
131+
}
132+
/* -----------------END OF PROGRAM --------------------*/
133+
/*
134+
* stuff you should look before submission
135+
* constraint and time limit
136+
* int overflow
137+
* special test case (n=0||n=1||n=2)
138+
* don't get stuck on one approach if you get wrong answer
139+
*/

Codeforces/1360D-Buying_Sholvels.cpp

+122
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
/*
2+
written by Pankaj Kumar.
3+
country:-INDIA
4+
Institute: National Institute of Technology, Uttarakhand
5+
*/
6+
#include <bits/stdc++.h>
7+
#include <ext/pb_ds/assoc_container.hpp>
8+
#include <ext/pb_ds/tree_policy.hpp>
9+
using namespace std;
10+
using namespace __gnu_pbds;
11+
typedef long long ll ;
12+
typedef vector<ll> vl;
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+
#define Endl "\n"
21+
// loops
22+
#define forin(arr,n) for(ll i=0;i<n;i++) cin>>arr[i];
23+
// Some print
24+
#define no cout<<"NO"<<endl;
25+
#define yes cout<<"YES"<<endl;
26+
// sort
27+
#define all(V) (V).begin(),(V).end()
28+
#define srt(V) sort(all(V))
29+
#define srtGreat(V) sort(all(V),greater<ll>())
30+
// some extra
31+
#define printv(v) for(ll i=0;i<ll(v.size());i++){cout<<v[i]<<" ";} line;
32+
#define precision(x) cout<<fixed<<setprecision(x);
33+
#define sz(V) ll(V.size())
34+
// template
35+
template <typename T>
36+
T mymax(T x,T y)
37+
{
38+
return (x>y)?x:y;
39+
}
40+
// function
41+
ll power(ll x,ll y,ll mod)
42+
{
43+
ll res=1;
44+
// x=x%mod;
45+
while(y>0)
46+
{
47+
if(y%2==1)
48+
{
49+
res*=x;
50+
// res=res%mod;
51+
}
52+
y/=2; x*=x; // x=x%mod;
53+
}
54+
return res;
55+
}
56+
ll str_to_num(string s)
57+
{
58+
return stoi(s);
59+
}
60+
61+
string num_to_str(ll num)
62+
{
63+
return to_string(num);
64+
}
65+
// datatype definination
66+
#define ordered_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
67+
class Point
68+
{
69+
public:
70+
ll x;
71+
ll y;
72+
ll z;
73+
ll getsum()
74+
{
75+
return x+y+z;
76+
}
77+
};
78+
/* ascii value
79+
A=65,Z=90,a=97,z=122
80+
*/
81+
/* --------------------MAIN PROGRAM----------------------------*/
82+
// to run ctrl+b
83+
84+
ll solve()
85+
{
86+
ll n,k;
87+
cin>>n>>k;
88+
ll mini=LONG_MAX;
89+
for(ll i=1;i*i<=n;i++){
90+
if(n%i==0){
91+
if(i<=k)
92+
mini=min(mini,n/i);
93+
if((n/i)<=k)
94+
mini=min(mini,i);
95+
}
96+
}
97+
cout<<mini<<endl;
98+
return 0;
99+
}
100+
101+
int main()
102+
{
103+
speed;
104+
/* #ifndef ONLINE_JUDGE
105+
freopen("input.txt","r",stdin);
106+
freopen("output.txt","w",stdout);
107+
#endif */
108+
ll TestCase=1;
109+
cin>>TestCase;
110+
while(TestCase--)
111+
{
112+
solve();
113+
}
114+
}
115+
/* -----------------END OF PROGRAM --------------------*/
116+
/*
117+
* stuff you should look before submission
118+
* constraint and time limit
119+
* int overflow
120+
* special test case (n=0||n=1||n=2)
121+
* don't get stuck on one approach if you get wrong answer
122+
*/

Codeforces/1360E-Polygon.cpp

+130
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
/*
2+
written by Pankaj Kumar.
3+
country:-INDIA
4+
Institute: National Institute of Technology, Uttarakhand
5+
*/
6+
#include <bits/stdc++.h>
7+
#include <ext/pb_ds/assoc_container.hpp>
8+
#include <ext/pb_ds/tree_policy.hpp>
9+
using namespace std;
10+
using namespace __gnu_pbds;
11+
typedef long long ll ;
12+
typedef vector<ll> vl;
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+
#define Endl "\n"
21+
// loops
22+
#define forin(arr,n) for(ll i=0;i<n;i++) cin>>arr[i];
23+
// Some print
24+
#define no cout<<"NO"<<endl;
25+
#define yes cout<<"YES"<<endl;
26+
// sort
27+
#define all(V) (V).begin(),(V).end()
28+
#define srt(V) sort(all(V))
29+
#define srtGreat(V) sort(all(V),greater<ll>())
30+
// some extra
31+
#define printv(v) for(ll i=0;i<ll(v.size());i++){cout<<v[i]<<" ";} line;
32+
#define precision(x) cout<<fixed<<setprecision(x);
33+
#define sz(V) ll(V.size())
34+
// template
35+
template <typename T>
36+
T mymax(T x,T y)
37+
{
38+
return (x>y)?x:y;
39+
}
40+
// function
41+
ll power(ll x,ll y,ll mod)
42+
{
43+
ll res=1;
44+
// x=x%mod;
45+
while(y>0)
46+
{
47+
if(y%2==1)
48+
{
49+
res*=x;
50+
// res=res%mod;
51+
}
52+
y/=2; x*=x; // x=x%mod;
53+
}
54+
return res;
55+
}
56+
ll str_to_num(string s)
57+
{
58+
return stoi(s);
59+
}
60+
61+
string num_to_str(ll num)
62+
{
63+
return to_string(num);
64+
}
65+
// datatype definination
66+
#define ordered_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
67+
class Point
68+
{
69+
public:
70+
ll x;
71+
ll y;
72+
ll z;
73+
ll getsum()
74+
{
75+
return x+y+z;
76+
}
77+
};
78+
/* ascii value
79+
A=65,Z=90,a=97,z=122
80+
*/
81+
/* --------------------MAIN PROGRAM----------------------------*/
82+
// to run ctrl+b
83+
84+
ll solve()
85+
{
86+
ll n;
87+
cin>>n;
88+
char v[n][n];
89+
for(ll i=0;i<n;i++){
90+
for(ll j=0;j<n;j++){
91+
cin>>v[i][j];
92+
}
93+
}
94+
for(ll i=0;i<n-1;i++){
95+
for(ll j=0;j<n-1;j++){
96+
if(v[i][j]=='1'){
97+
if(v[i+1][j]!='1'&&v[i][j+1]!='1'){
98+
no
99+
return 0;
100+
}
101+
}
102+
}
103+
}
104+
yes
105+
106+
return 0;
107+
}
108+
109+
int main()
110+
{
111+
speed;
112+
/* #ifndef ONLINE_JUDGE
113+
freopen("input.txt","r",stdin);
114+
freopen("output.txt","w",stdout);
115+
#endif */
116+
ll TestCase=1;
117+
cin>>TestCase;
118+
while(TestCase--)
119+
{
120+
solve();
121+
}
122+
}
123+
/* -----------------END OF PROGRAM --------------------*/
124+
/*
125+
* stuff you should look before submission
126+
* constraint and time limit
127+
* int overflow
128+
* special test case (n=0||n=1||n=2)
129+
* don't get stuck on one approach if you get wrong answer
130+
*/

0 commit comments

Comments
 (0)