Skip to content

Commit 2dfc874

Browse files
committed
cf div3 round 690
1 parent 8d5b416 commit 2dfc874

5 files changed

+422
-0
lines changed

Diff for: codeforces/1462A-Favorite_Sequence.cpp

+107
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
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+
#define speed cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
13+
// define values.
14+
// #define mod 1000000007
15+
#define phi 1.618
16+
/* Abbrevations */
17+
#define ff first
18+
#define ss second
19+
#define mp make_pair
20+
#define line cout<<endl;
21+
#define pb push_back
22+
#define Endl "\n"
23+
// loops
24+
#define forin(arr,n) for(ll i=0;i<n;i++) cin>>arr[i];
25+
// Some print
26+
#define no cout<<"NO"<<endl;
27+
#define yes cout<<"YES"<<endl;
28+
#define cc ll test;cin>>test;while(test--)
29+
// sort
30+
#define all(V) (V).begin(),(V).end()
31+
#define srt(V) sort(all(V))
32+
#define srtGreat(V) sort(all(V),greater<ll>())
33+
#define printv(v) for(ll i=0;i<ll(v.size());i++){cout<<v[i]<<" ";} line;
34+
// some extra
35+
#define sz(V) ll(V.size())
36+
/* ONLINE JUDGE */
37+
// #ifdef ONLINE_JUDGE
38+
// freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
39+
// #endif
40+
// function
41+
42+
ll power(ll x,ll y,ll mod)
43+
{
44+
ll res=1;
45+
// x=x%mod;
46+
while(y>0)
47+
{
48+
if(y%2==1)
49+
{
50+
res*=x;
51+
// res=res%mod;
52+
}
53+
y/=2; x*=x; // x=x%mod;
54+
}
55+
return res;
56+
}
57+
// datatype definination
58+
#define ordered_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
59+
60+
/* ascii value
61+
A=65,Z=90,a=97,z=122
62+
*/
63+
/* -----------------------------------------------------------------------------------*/
64+
65+
ll solve()
66+
{
67+
ll n;
68+
cin>>n;
69+
vl ans,v(n);
70+
forin(v,n);
71+
ll flag=0,pos1=0,pos2=n-1;
72+
for(ll i=0;i<n;i++)
73+
{
74+
if(flag==0)
75+
{
76+
flag=1;
77+
ans.pb(v[pos1]);
78+
pos1++;
79+
}
80+
else
81+
{
82+
flag=0;
83+
ans.pb(v[pos2]);
84+
pos2--;
85+
}
86+
}
87+
printv(ans);
88+
return 0;
89+
}
90+
91+
int main()
92+
{
93+
speed;
94+
// freopen("input.txt","r",stdin);
95+
// freopen("output.txt","w",stdout);
96+
// solve();
97+
cc
98+
{
99+
solve();
100+
}
101+
}
102+
103+
/* stuff you should look before submission
104+
* int overflow
105+
* special test case (n=0||n=1||n=2)
106+
* don't get stuck on one approach if you get wrong answer
107+
*/

Diff for: codeforces/1462B-Last_Year's_Substring.cpp

+100
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
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+
#define speed cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
13+
// define values.
14+
// #define mod 1000000007
15+
#define phi 1.618
16+
/* Abbrevations */
17+
#define ff first
18+
#define ss second
19+
#define mp make_pair
20+
#define line cout<<endl;
21+
#define pb push_back
22+
#define Endl "\n"
23+
// loops
24+
#define forin(arr,n) for(ll i=0;i<n;i++) cin>>arr[i];
25+
// Some print
26+
#define no cout<<"NO"<<endl;
27+
#define yes cout<<"YES"<<endl;
28+
#define cc ll test;cin>>test;while(test--)
29+
// sort
30+
#define all(V) (V).begin(),(V).end()
31+
#define srt(V) sort(all(V))
32+
#define srtGreat(V) sort(all(V),greater<ll>())
33+
#define printv(v) for(ll i=0;i<ll(v.size());i++){cout<<v[i]<<" ";} line;
34+
// some extra
35+
#define sz(V) ll(V.size())
36+
/* ONLINE JUDGE */
37+
// #ifdef ONLINE_JUDGE
38+
// freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
39+
// #endif
40+
// function
41+
42+
ll power(ll x,ll y,ll mod)
43+
{
44+
ll res=1;
45+
// x=x%mod;
46+
while(y>0)
47+
{
48+
if(y%2==1)
49+
{
50+
res*=x;
51+
// res=res%mod;
52+
}
53+
y/=2; x*=x; // x=x%mod;
54+
}
55+
return res;
56+
}
57+
// datatype definination
58+
#define ordered_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
59+
60+
/* ascii value
61+
A=65,Z=90,a=97,z=122
62+
*/
63+
/* -----------------------------------------------------------------------------------*/
64+
65+
ll solve()
66+
{
67+
ll n;
68+
string s;
69+
cin>>n>>s;
70+
if(s[0]=='2'&&s[n-1]=='0'&&s[n-2]=='2'&&s[n-3]=='0')
71+
yes
72+
else if(s[0]=='2'&&s[1]=='0'&&s[n-1]=='0'&&s[n-2]=='2')
73+
yes
74+
else if(s[0]=='2'&&s[1]=='0'&&s[2]=='2'&&s[n-1]=='0')
75+
yes
76+
else if(s[0]=='2'&&s[1]=='0'&&s[2]=='2'&&s[3]=='0')
77+
yes
78+
else if(s[n-4]=='2'&&s[n-3]=='0'&&s[n-2]=='2'&&s[n-1]=='0')
79+
yes
80+
else
81+
no
82+
return 0;
83+
}
84+
85+
int main()
86+
{
87+
speed;
88+
// freopen("input.txt","r",stdin);
89+
// freopen("output.txt","w",stdout);
90+
cc
91+
{
92+
solve();
93+
}
94+
}
95+
96+
/* stuff you should look before submission
97+
* int overflow
98+
* special test case (n=0||n=1||n=2)
99+
* don't get stuck on one approach if you get wrong answer
100+
*/

Diff for: codeforces/1462C-Unique_Number.cpp

+117
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
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+
#define speed cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
13+
// define values.
14+
// #define mod 1000000007
15+
#define phi 1.618
16+
/* Abbrevations */
17+
#define ff first
18+
#define ss second
19+
#define mp make_pair
20+
#define line cout<<endl;
21+
#define pb push_back
22+
#define Endl "\n"
23+
// loops
24+
#define forin(arr,n) for(ll i=0;i<n;i++) cin>>arr[i];
25+
// Some print
26+
#define no cout<<"NO"<<endl;
27+
#define yes cout<<"YES"<<endl;
28+
#define cc ll test;cin>>test;while(test--)
29+
// sort
30+
#define all(V) (V).begin(),(V).end()
31+
#define srt(V) sort(all(V))
32+
#define srtGreat(V) sort(all(V),greater<ll>())
33+
#define printv(v) for(ll i=0;i<ll(v.size());i++){cout<<v[i]<<" ";} line;
34+
// some extra
35+
#define sz(V) ll(V.size())
36+
/* ONLINE JUDGE */
37+
// #ifdef ONLINE_JUDGE
38+
// freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
39+
// #endif
40+
// function
41+
42+
ll power(ll x,ll y,ll mod)
43+
{
44+
ll res=1;
45+
// x=x%mod;
46+
while(y>0)
47+
{
48+
if(y%2==1)
49+
{
50+
res*=x;
51+
// res=res%mod;
52+
}
53+
y/=2; x*=x; // x=x%mod;
54+
}
55+
return res;
56+
}
57+
ll str_to_num(string s)
58+
{
59+
return stoi(s);
60+
}
61+
62+
string num_to_str(ll num)
63+
{
64+
return to_string(num);
65+
}
66+
// datatype definination
67+
#define ordered_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
68+
69+
/* ascii value
70+
A=65,Z=90,a=97,z=122
71+
*/
72+
/* -----------------------------------------------------------------------------------*/
73+
74+
ll solve()
75+
{
76+
ll n;
77+
cin>>n;
78+
if(n>45)
79+
{
80+
cout<<-1<<endl;
81+
return 0;
82+
}
83+
else
84+
{
85+
string ans="";
86+
ll pos=9;
87+
while(pos>0)
88+
{
89+
if(n>=pos)
90+
{
91+
ans+=num_to_str(pos);
92+
n-=pos;
93+
}
94+
pos--;
95+
}
96+
srt(ans);
97+
cout<<ans<<endl;
98+
}
99+
return 0;
100+
}
101+
102+
int main()
103+
{
104+
speed;
105+
// freopen("input.txt","r",stdin);
106+
// freopen("output.txt","w",stdout);
107+
cc
108+
{
109+
solve();
110+
}
111+
}
112+
113+
/* stuff you should look before submission
114+
* int overflow
115+
* special test case (n=0||n=1||n=2)
116+
* don't get stuck on one approach if you get wrong answer
117+
*/

0 commit comments

Comments
 (0)