Skip to content

Commit 4044153

Browse files
committed
weekly contest
1 parent 7270435 commit 4044153

11 files changed

+745
-0
lines changed

Atcoder/ABC/abc278_A-Shift.cpp

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
written by Pankaj Kumar.
3+
country:-INDIA
4+
*/
5+
#include <bits/stdc++.h>
6+
using namespace std;
7+
typedef long long ll;
8+
9+
10+
/* ascii value
11+
A=65,Z=90,a=97,z=122
12+
*/
13+
14+
// Techniques :
15+
// divide into cases, brute force, pattern finding
16+
// sort, greedy, binary search, two pointer
17+
// transform into graph
18+
19+
20+
int solve(){
21+
int n,m;
22+
cin>>n>>m;
23+
vector<int> v(n);
24+
for(int i=0;i<n;i++){
25+
cin>>v[i];
26+
}
27+
for(int i=m;i<n+m;i++){
28+
if(i>=n){
29+
cout<<0<<" ";
30+
}
31+
else{
32+
cout<<v[i]<<" ";
33+
}
34+
}
35+
cout<<endl;
36+
return 0;
37+
}
38+
int main()
39+
{
40+
long long testCase=1;
41+
while(testCase--){
42+
solve();
43+
}
44+
return 0;
45+
}
46+
/* -----------------END OF PROGRAM --------------------*/
47+
/*
48+
* stuff you should look before submission
49+
* constraint and time limit
50+
* int overflow
51+
* special test case (n=0||n=1||n=2)
52+
* don't get stuck on one approach if you get wrong answer
53+
*/

Atcoder/ABC/abc278_C-FF.cpp

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
written by Pankaj Kumar.
3+
country:-INDIA
4+
*/
5+
#include <bits/stdc++.h>
6+
using namespace std;
7+
typedef long long ll;
8+
9+
10+
/* ascii value
11+
A=65,Z=90,a=97,z=122
12+
*/
13+
14+
// Techniques :
15+
// divide into cases, brute force, pattern finding
16+
// sort, greedy, binary search, two pointer
17+
// transform into graph
18+
19+
20+
int solve(){
21+
int n,q;
22+
cin>>n>>q;
23+
map<pair<int,int>,bool> mp;
24+
while(q--){
25+
int t,a,b;
26+
cin>>t>>a>>b;
27+
if(t==1){
28+
mp[{b,a}]=true;
29+
}
30+
else if(t==2){
31+
mp[{b,a}]=false;
32+
}
33+
else{
34+
if(mp[{a,b}] && mp[{b,a}]){
35+
cout<<"Yes"<<endl;
36+
}
37+
else{
38+
cout<<"No"<<endl;
39+
}
40+
}
41+
}
42+
return 0;
43+
}
44+
int main()
45+
{
46+
long long testCase=1;
47+
while(testCase--){
48+
solve();
49+
}
50+
return 0;
51+
}
52+
/* -----------------END OF PROGRAM --------------------*/
53+
/*
54+
* stuff you should look before submission
55+
* constraint and time limit
56+
* int overflow
57+
* special test case (n=0||n=1||n=2)
58+
* don't get stuck on one approach if you get wrong answer
59+
*/
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
/*
2+
written by Pankaj Kumar.
3+
country:-INDIA
4+
*/
5+
#include <bits/stdc++.h>
6+
using namespace std;
7+
typedef long long ll;
8+
9+
10+
/* ascii value
11+
A=65,Z=90,a=97,z=122
12+
*/
13+
14+
// Techniques :
15+
// divide into cases, brute force, pattern finding
16+
// sort, greedy, binary search, two pointer
17+
// transform into graph
18+
19+
ll solve()
20+
{
21+
ll n;
22+
cin >> n;
23+
ll a, b, c;
24+
cin >> a >> b >> c;
25+
map<char, ll> m;
26+
m['R'] = a;
27+
m['P'] = b;
28+
m['S'] = c;
29+
string s, ans = "";
30+
ll win = 0, lose = 0;
31+
cin >> s;
32+
for (auto x : s)
33+
{
34+
if (x == 'R')
35+
{
36+
if (m['P'] > 0)
37+
{
38+
win++;
39+
m['P']--;
40+
b--;
41+
ans += 'P';
42+
}
43+
else
44+
ans += '@';
45+
}
46+
else if (x == 'P')
47+
{
48+
if (m['S'] > 0)
49+
{
50+
c--;
51+
win++;
52+
m['S']--;
53+
ans += 'S';
54+
}
55+
else
56+
ans += '@';
57+
}
58+
else if (x == 'S')
59+
{
60+
if (m['R'] > 0)
61+
{
62+
a--;
63+
win++;
64+
m['R']--;
65+
ans += 'R';
66+
}
67+
else
68+
ans += '@';
69+
}
70+
}
71+
if (win >= ((n + 1) / 2))
72+
{
73+
cout<<"YES"<<endl;
74+
for (ll i = 0; i < n; i++)
75+
{
76+
if (ans[i] == '@')
77+
{
78+
if (a > 0)
79+
{
80+
a--;
81+
ans[i] = 'R';
82+
}
83+
else if (b > 0)
84+
{
85+
b--;
86+
ans[i] = 'P';
87+
}
88+
else
89+
{
90+
c--;
91+
ans[i] = 'S';
92+
}
93+
}
94+
}
95+
cout << ans << endl;
96+
}
97+
else{
98+
cout<<"NO"<<endl;
99+
}
100+
return 0;
101+
}
102+
103+
int main()
104+
{
105+
long long testCase;
106+
cin>>testCase;
107+
while(testCase--){
108+
solve();
109+
}
110+
return 0;
111+
}
112+
/* -----------------END OF PROGRAM --------------------*/
113+
/*
114+
* stuff you should look before submission
115+
* constraint and time limit
116+
* int overflow
117+
* special test case (n=0||n=1||n=2)
118+
* don't get stuck on one approach if you get wrong answer
119+
*/
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
written by Pankaj Kumar.
3+
country:-INDIA
4+
*/
5+
#include <bits/stdc++.h>
6+
using namespace std;
7+
typedef long long ll;
8+
9+
10+
/* ascii value
11+
A=65,Z=90,a=97,z=122
12+
*/
13+
14+
// Techniques :
15+
// divide into cases, brute force, pattern finding
16+
// sort, greedy, binary search, two pointer
17+
// transform into graph
18+
19+
20+
int solve(){
21+
int n,z;
22+
cin>>n>>z;
23+
int maxo=0;
24+
for(int i=0;i<n;i++){
25+
int temp;
26+
cin>>temp;
27+
maxo=max(maxo,temp|z);
28+
}
29+
cout<<maxo<<endl;
30+
return 0;
31+
}
32+
int main()
33+
{
34+
long long testCase;
35+
cin>>testCase;
36+
while(testCase--){
37+
solve();
38+
}
39+
return 0;
40+
}
41+
/* -----------------END OF PROGRAM --------------------*/
42+
/*
43+
* stuff you should look before submission
44+
* constraint and time limit
45+
* int overflow
46+
* special test case (n=0||n=1||n=2)
47+
* don't get stuck on one approach if you get wrong answer
48+
*/
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
written by Pankaj Kumar.
3+
country:-INDIA
4+
*/
5+
#include <bits/stdc++.h>
6+
using namespace std;
7+
typedef long long ll;
8+
9+
10+
/* ascii value
11+
A=65,Z=90,a=97,z=122
12+
*/
13+
14+
// Techniques :
15+
// divide into cases, brute force, pattern finding
16+
// sort, greedy, binary search, two pointer
17+
// transform into graph
18+
19+
20+
int solve(){
21+
int n;
22+
cin>>n;
23+
vector<int> v(n+1,0);
24+
int ans=0;
25+
for (int i = 1; i <= n; i++)
26+
{
27+
cin >> v[i];
28+
if (v[i - 1] == 0 && v[i] != 0){
29+
ans++;
30+
}
31+
}
32+
ans=min(ans,2);
33+
cout << ans << endl;
34+
return 0;
35+
}
36+
int main()
37+
{
38+
long long testCase;
39+
cin>>testCase;
40+
while(testCase--){
41+
solve();
42+
}
43+
return 0;
44+
}
45+
/* -----------------END OF PROGRAM --------------------*/
46+
/*
47+
* stuff you should look before submission
48+
* constraint and time limit
49+
* int overflow
50+
* special test case (n=0||n=1||n=2)
51+
* don't get stuck on one approach if you get wrong answer
52+
*/

0 commit comments

Comments
 (0)