Skip to content

Commit 73c9cfc

Browse files
committed
Third Checkpoint reachedgit add .
1 parent eddd71b commit 73c9cfc

File tree

77 files changed

+6104
-294
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+6104
-294
lines changed

A.cpp

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
using namespace std::chrono;
4+
typedef long long ll;
5+
typedef long double ld;
6+
struct custom_hash;
7+
#define ff first
8+
#define I insert
9+
#define ss second
10+
#define maxN 300002
11+
#define inf INT_MAX
12+
#define ninf INT_MIN
13+
#define pb push_back
14+
#define popb pop_back
15+
#define pf push_front
16+
#define pi 3.14159265
17+
#define ub upper_bound
18+
#define lb lower_bound
19+
#define popf pop_front
20+
#define mod 1000000007
21+
#define vi vector<int>
22+
#define mll map<ll, ll>
23+
#define vll vector <ll>
24+
const int dx4[]={-1,0,1,0};
25+
const int dy4[]={0,1,0,-1};
26+
#define vvi vector<vector<int> >
27+
#define all(v) v.begin(), v.end()
28+
#define rall(v) v.rbegin(), v.rend()
29+
const int dx8[]={-1,-1,-1,0,1,1,1,0,-1};
30+
const int dy8[]={-1,0,1,1,1,0,-1,-1,-1};
31+
#define ust unordered_set<ll, custom_hash>
32+
#define rep(i, a, b) for(ll i = a; i < b; i++)
33+
#define umll unordered_map<ll, ll, custom_hash>
34+
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
35+
struct custom_hash { size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM =
36+
chrono::steady_clock::now().time_since_epoch().count();x ^= FIXED_RANDOM;return x ^ (x >> 16);}};
37+
ll power(ll x,ll n) {ll result=1; while(n) {if(n%2==1) result=result*x; n=n/2; x=x*x;} return result;}
38+
ll gcd(ll a, ll b) {return b ? gcd(b, a%b) : a;}
39+
ll lcm(ll a , ll b){return (a*b)/gcd(a,b);}
40+
ll BS(ll a[],ll s,ll n,ll val) {ll mid,beg=s,end=n-1; while(beg<=end)
41+
{mid=(beg+end)/2; if(val==a[mid]){break;} else if(val>a[mid]){beg=mid+1;}else{end=mid-1;}} return mid;}
42+
inline ll mul(ll x,ll y,ll m){ll z=1LL*x*y;if (z>=m){z%=m;} return z;}
43+
ll powmod(ll x,ll y,ll m){ll r=1;while(y){if(y&1){r=mul(r,x,m);}y>>=1;x=mul(x,x,m);}return r;}
44+
45+
//========================================XXXXXXXXXXXXXXXX=======================================
46+
47+
void solve() {
48+
49+
}
50+
51+
int main() {
52+
fast;
53+
#ifndef ONLINE_JUDGE
54+
freopen("input.txt", "r", stdin);
55+
freopen("output.txt", "w", stdout);
56+
#endif
57+
int t = 1;
58+
cin >> t;
59+
while(t--)
60+
solve();
61+
return 0;
62+
}

Acacius and String.cpp

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
using namespace std::chrono;
4+
typedef long long ll;
5+
typedef long double ld;
6+
struct custom_hash;
7+
#define ff first
8+
#define I insert
9+
#define ss second
10+
#define maxN 300002
11+
#define inf INT_MAX
12+
#define ninf INT_MIN
13+
#define pb push_back
14+
#define popb pop_back
15+
#define pf push_front
16+
#define pi 3.14159265
17+
#define ub upper_bound
18+
#define lb lower_bound
19+
#define popf pop_front
20+
#define mod 1000000007
21+
#define vi vector<int>
22+
#define mll map<ll, ll>
23+
#define vll vector <ll>
24+
const int dx4[]={-1,0,1,0};
25+
const int dy4[]={0,1,0,-1};
26+
#define vvi vector<vector<int> >
27+
#define all(v) v.begin(), v.end()
28+
#define rall(v) v.rbegin(), v.rend()
29+
const int dx8[]={-1,-1,-1,0,1,1,1,0,-1};
30+
const int dy8[]={-1,0,1,1,1,0,-1,-1,-1};
31+
#define ust unordered_set<ll, custom_hash>
32+
#define rep(i, a, b) for(ll i = a; i < b; i++)
33+
#define umll unordered_map<ll, ll, custom_hash>
34+
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
35+
struct custom_hash { size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM =
36+
chrono::steady_clock::now().time_since_epoch().count();x ^= FIXED_RANDOM;return x ^ (x >> 16);}};
37+
ll power(ll x,ll n) {ll result=1; while(n) {if(n%2==1) result=result*x; n=n/2; x=x*x;} return result;}
38+
ll gcd(ll a, ll b) {return b ? gcd(b, a%b) : a;}
39+
ll lcm(ll a , ll b){return (a*b)/gcd(a,b);}
40+
ll BS(ll a[],ll s,ll n,ll val) {ll mid,beg=s,end=n-1; while(beg<=end)
41+
{mid=(beg+end)/2; if(val==a[mid]){break;} else if(val>a[mid]){beg=mid+1;}else{end=mid-1;}} return mid;}
42+
inline ll mul(ll x,ll y,ll m){ll z=1LL*x*y;if (z>=m){z%=m;} return z;}
43+
ll powmod(ll x,ll y,ll m){ll r=1;while(y){if(y&1){r=mul(r,x,m);}y>>=1;x=mul(x,x,m);}return r;}
44+
45+
//========================================XXXXXXXXXXXXXXXX=======================================
46+
// Important Edge Case ->
47+
// 1
48+
// 13
49+
// abacab?bacaba
50+
51+
string comp = "abacaba";
52+
53+
int countSS(string &s) {
54+
int len = s.size(), cnt = 0;
55+
rep(i, 0, len) {
56+
if(s.substr(i, comp.size()) == comp)
57+
cnt++;
58+
}
59+
return cnt;
60+
}
61+
62+
void solve() {
63+
int n, cnt, len;
64+
string s;
65+
cin >> n >> s;
66+
len = s.length();
67+
cnt = countSS(s);
68+
//cout << cnt << "\n";
69+
if(cnt > 1) {
70+
cout << "NO\n";
71+
}
72+
else if(cnt == 1) {
73+
cout << "YES\n";
74+
rep(i, 0, len) {
75+
if(s[i] == '?')
76+
s[i] = 'z';
77+
}
78+
cout << s << "\n";
79+
}
80+
else {
81+
for(int i = 0; i + comp.size() <= n; i++) {
82+
string ss = s;
83+
bool ok = true;
84+
for(int j = 0; j < comp.size(); j++) {
85+
if(ss[i + j] != '?' && ss[i + j] != comp[j]) {
86+
ok = false;
87+
break;
88+
}
89+
ss[i + j] = comp[j];
90+
}
91+
if(ok && countSS(ss) == 1) {
92+
rep(j, 0, n) {
93+
if(ss[j] == '?')
94+
ss[j] = 'z';
95+
}
96+
cout << "YES\n";
97+
cout << ss << "\n";
98+
return;
99+
}
100+
}
101+
cout << "NO\n";
102+
}
103+
}
104+
105+
int main() {
106+
fast;
107+
#ifndef ONLINE_JUDGE
108+
freopen("input.txt", "r", stdin);
109+
freopen("output.txt", "w", stdout);
110+
#endif
111+
int t = 1;
112+
cin >> t;
113+
while(t--)
114+
solve();
115+
return 0;
116+
}

Arranging boxes - 2.cpp

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
using namespace std::chrono;
4+
typedef long long ll;
5+
typedef long double ld;
6+
struct custom_hash;
7+
#define ff first
8+
#define I insert
9+
#define ss second
10+
#define maxN 300002
11+
#define inf INT_MAX
12+
#define ninf INT_MIN
13+
#define pb push_back
14+
#define popb pop_back
15+
#define pf push_front
16+
#define pi 3.14159265
17+
#define ub upper_bound
18+
#define lb lower_bound
19+
#define popf pop_front
20+
#define mod 1000000007
21+
#define vi vector<int>
22+
#define mll map<ll, ll>
23+
#define vll vector <ll>
24+
const int dx4[]={-1,0,1,0};
25+
const int dy4[]={0,1,0,-1};
26+
#define vvi vector<vector<int> >
27+
#define all(v) v.begin(), v.end()
28+
#define rall(v) v.rbegin(), v.rend()
29+
const int dx8[]={-1,-1,-1,0,1,1,1,0,-1};
30+
const int dy8[]={-1,0,1,1,1,0,-1,-1,-1};
31+
#define ust unordered_set<ll, custom_hash>
32+
#define rep(i, a, b) for(ll i = a; i < b; i++)
33+
#define umll unordered_map<ll, ll, custom_hash>
34+
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
35+
struct custom_hash { size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM =
36+
chrono::steady_clock::now().time_since_epoch().count();x ^= FIXED_RANDOM;return x ^ (x >> 16);}};
37+
ll power(ll x,ll n) {ll result=1; while(n) {if(n%2==1) result=result*x; n=n/2; x=x*x;} return result;}
38+
ll gcd(ll a, ll b) {return b ? gcd(b, a%b) : a;}
39+
ll lcm(ll a , ll b){return (a*b)/gcd(a,b);}
40+
ll BS(ll a[],ll s,ll n,ll val) {ll mid,beg=s,end=n-1; while(beg<=end)
41+
{mid=(beg+end)/2; if(val==a[mid]){break;} else if(val>a[mid]){beg=mid+1;}else{end=mid-1;}} return mid;}
42+
inline ll mul(ll x,ll y,ll m){ll z=1LL*x*y;if (z>=m){z%=m;} return z;}
43+
ll powmod(ll x,ll y,ll m){ll r=1;while(y){if(y&1){r=mul(r,x,m);}y>>=1;x=mul(x,x,m);}return r;}
44+
45+
//========================================XXXXXXXXXXXXXXXX=======================================
46+
47+
void LIS() {
48+
int n;
49+
cin >> n;
50+
vi a(n), tails(n + 1, inf);
51+
rep(i, 0, n) {
52+
cin >> a[i];
53+
}
54+
tails[0] = ninf;
55+
rep(i, 0, n) {
56+
int j = upper_bound(all(tails), a[i]) - tails.begin();
57+
if (tails[j-1] < a[i] && a[i] < tails[j])
58+
tails[j] = a[i];
59+
}
60+
int ans = 0;
61+
rep(i, 0, n + 1) {
62+
if(tails[i] < inf)
63+
ans = i;
64+
}
65+
cout << n - ans << "\n";
66+
}
67+
68+
int main() {
69+
fast;
70+
#ifndef ONLINE_JUDGE
71+
freopen("input.txt", "r", stdin);
72+
freopen("output.txt", "w", stdout);
73+
#endif
74+
int t = 1;
75+
//cin >> t;
76+
while(t--)
77+
LIS();
78+
return 0;
79+
}

Array Walk.cpp

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
using namespace std::chrono;
4+
typedef long long ll;
5+
typedef long double ld;
6+
struct custom_hash;
7+
#define ff first
8+
#define I insert
9+
#define ss second
10+
#define maxN 300002
11+
#define inf INT_MAX
12+
#define ninf INT_MIN
13+
#define pb push_back
14+
#define popb pop_back
15+
#define pf push_front
16+
#define pi 3.14159265
17+
#define ub upper_bound
18+
#define lb lower_bound
19+
#define popf pop_front
20+
#define mod 1000000007
21+
#define vi vector<int>
22+
#define mll map<ll, ll>
23+
#define vll vector <ll>
24+
const int dx4[]={-1,0,1,0};
25+
const int dy4[]={0,1,0,-1};
26+
#define vvi vector<vector<int> >
27+
#define all(v) v.begin(), v.end()
28+
#define rall(v) v.rbegin(), v.rend()
29+
const int dx8[]={-1,-1,-1,0,1,1,1,0,-1};
30+
const int dy8[]={-1,0,1,1,1,0,-1,-1,-1};
31+
#define ust unordered_set<ll, custom_hash>
32+
#define rep(i, a, b) for(ll i = a; i < b; i++)
33+
#define umll unordered_map<ll, ll, custom_hash>
34+
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
35+
struct custom_hash { size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM =
36+
chrono::steady_clock::now().time_since_epoch().count();x ^= FIXED_RANDOM;return x ^ (x >> 16);}};
37+
ll power(ll x,ll n) {ll result=1; while(n) {if(n%2==1) result=result*x; n=n/2; x=x*x;} return result;}
38+
ll gcd(ll a, ll b) {return b ? gcd(b, a%b) : a;}
39+
ll lcm(ll a , ll b){return (a*b)/gcd(a,b);}
40+
ll BS(ll a[],ll s,ll n,ll val) {ll mid,beg=s,end=n-1; while(beg<=end)
41+
{mid=(beg+end)/2; if(val==a[mid]){break;} else if(val>a[mid]){beg=mid+1;}else{end=mid-1;}} return mid;}
42+
inline ll mul(ll x,ll y,ll m){ll z=1LL*x*y;if (z>=m){z%=m;} return z;}
43+
ll powmod(ll x,ll y,ll m){ll r=1;while(y){if(y&1){r=mul(r,x,m);}y>>=1;x=mul(x,x,m);}return r;}
44+
45+
//========================================XXXXXXXXXXXXXXXX=======================================
46+
47+
void solve() {
48+
int n, k, z, ans = 0;
49+
cin >> n >> k >> z;
50+
vi a(n);
51+
rep(i, 0, n) {
52+
cin >> a[i];
53+
}
54+
rep(i, 0, z + 1) {
55+
int mpos = k - 2 * i;
56+
if(mpos < 0) break;
57+
int sx = 0, mx = 0;
58+
rep(j, 0, mpos + 1) {
59+
sx += a[j];
60+
if(j < n - 1)
61+
mx = max(mx, a[j] + a[j + 1]);
62+
}
63+
ans = max(ans, int(sx + (mx * i)));
64+
}
65+
cout << ans << "\n";
66+
}
67+
68+
int main() {
69+
fast;
70+
#ifndef ONLINE_JUDGE
71+
freopen("input.txt", "r", stdin);
72+
freopen("output.txt", "w", stdout);
73+
#endif
74+
int t = 1;
75+
cin >> t;
76+
while(t--)
77+
solve();
78+
return 0;
79+
}

0 commit comments

Comments
 (0)