Skip to content

Commit 44be173

Browse files
author
Koral Kulacoglu
committed
random div2 contest
1 parent 753810e commit 44be173

6 files changed

Lines changed: 475 additions & 0 deletions

File tree

CodeForces/Contests/1113/2/A

38.2 KB
Binary file not shown.

CodeForces/Contests/1113/2/A.cpp

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
/*
2+
ID: Koral Kulacoglu
3+
TASK: test
4+
LANG: C++
5+
*/
6+
7+
#pragma GCC optimize("O3")
8+
#pragma GCC target("sse4")
9+
10+
#include <bits/stdc++.h>
11+
12+
using namespace std;
13+
14+
typedef long long ll;
15+
typedef long double ld;
16+
typedef unsigned long long ull;
17+
typedef long double lld;
18+
typedef complex<ld> cd;
19+
20+
typedef pair<int, int> pi;
21+
typedef pair<ll, ll> pll;
22+
typedef pair<ld, ld> pld;
23+
24+
typedef vector<int> vi;
25+
typedef vector<string> vs;
26+
typedef vector<char> vc;
27+
typedef vector<ld> vld;
28+
typedef vector<ll> vll;
29+
typedef vector<pi> vpi;
30+
typedef vector<pll> vpll;
31+
typedef vector<cd> vcd;
32+
33+
template <class T> using pq = priority_queue<T>;
34+
template <class T> using pqg = priority_queue<T, vector<T>, greater<T>>;
35+
36+
#define FOR(i, a, b) for (int i = a; i < (b); i++)
37+
#define F0R(i, a) for (int i = 0; i < (a); i++)
38+
#define FORd(i, a, b) for (int i = (a) - 1; i >= b; i--)
39+
#define F0Rd(i, a) for (int i = (a) - 1; i >= 0; i--)
40+
#define trav(a, x) for (auto &a : x)
41+
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)
42+
43+
#define sz(x) (int)(x).size()
44+
#define all(x) x.begin(), x.end()
45+
#define mp make_pair
46+
#define pb push_back
47+
#define fir first
48+
#define sec second
49+
#define ins insert
50+
#define lbound(a, v) lower_bound(all(a), v) - a.begin()
51+
#define ubound(a, v) upper_bound(all(a), v) - a.begin()
52+
#define gcd(a, b) __gcd(a, b)
53+
#define lcm(a, b) (a * b) / gcd(a, b)
54+
55+
template <class T> bool ckmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; }
56+
template <class T> bool ckmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
57+
58+
void __print(int x) { cerr << x; }
59+
void __print(long x) { cerr << x; }
60+
void __print(long long x) { cerr << x; }
61+
void __print(unsigned x) { cerr << x; }
62+
void __print(unsigned long x) { cerr << x; }
63+
void __print(unsigned long long x) { cerr << x; }
64+
void __print(float x) { cerr << x; }
65+
void __print(double x) { cerr << x; }
66+
void __print(long double x) { cerr << x; }
67+
void __print(char x) { cerr << '\'' << x << '\''; }
68+
void __print(const char *x) { cerr << '\"' << x << '\"'; }
69+
void __print(const string &x) { cerr << '\"' << x << '\"'; }
70+
void __print(bool x) { cerr << (x ? "true" : "false"); }
71+
72+
template <typename T, typename V> void __print(const pair<T, V> &x);
73+
template <typename T> void __print(const T &x) {
74+
int f = 0;
75+
cerr << '{';
76+
for (auto &i : x)
77+
cerr << (f++ ? ", " : ""), __print(i);
78+
cerr << "}";
79+
}
80+
template <typename T, typename V> void __print(const pair<T, V> &x) {
81+
cerr << '{';
82+
__print(x.first);
83+
cerr << ", ";
84+
__print(x.second);
85+
cerr << '}';
86+
}
87+
void _print() { cerr << "]\n"; }
88+
template <typename T, typename... V> void _print(T t, V... v) {
89+
__print(t);
90+
if (sizeof...(v))
91+
cerr << ", ";
92+
_print(v...);
93+
}
94+
95+
#ifdef DEBUG
96+
#define dbg(x...) \
97+
cerr << __func__ << ":" << __LINE__ << " [" << #x << "] = ["; \
98+
_print(x); \
99+
cerr << endl;
100+
#else
101+
#define dbg(x...)
102+
#endif
103+
104+
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
105+
106+
struct custom_hash {
107+
size_t operator()(uint64_t x) const {
108+
x ^= rng();
109+
return x ^ (x >> 16);
110+
}
111+
};
112+
113+
const int MOD = 1000000007;
114+
const char nl = '\n';
115+
const int MX = 100001;
116+
117+
void solve() {
118+
string s;
119+
cin >> s;
120+
121+
bool zd = false, od = false;
122+
string res;
123+
for (char c : s) {
124+
if (c == '0') {
125+
if (!zd) {
126+
zd = true;
127+
continue;
128+
}
129+
res.push_back(c);
130+
}
131+
if (c == '1') {
132+
if (!od) {
133+
od = true;
134+
continue;
135+
}
136+
res.push_back(c);
137+
}
138+
}
139+
140+
cout << res << nl;
141+
}
142+
143+
int main() {
144+
cin.tie(0)->sync_with_stdio(0);
145+
cin.exceptions(cin.failbit);
146+
147+
int T = 1;
148+
cin >> T;
149+
while (T--) {
150+
solve();
151+
}
152+
153+
return 0;
154+
}

CodeForces/Contests/1113/2/B

37.8 KB
Binary file not shown.

CodeForces/Contests/1113/2/B.cpp

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
/*
2+
ID: Koral Kulacoglu
3+
TASK: test
4+
LANG: C++
5+
*/
6+
7+
#include <algorithm>
8+
#pragma GCC optimize("O3")
9+
#pragma GCC target("sse4")
10+
11+
#include <bits/stdc++.h>
12+
13+
using namespace std;
14+
15+
typedef long long ll;
16+
typedef long double ld;
17+
typedef unsigned long long ull;
18+
typedef long double lld;
19+
typedef complex<ld> cd;
20+
21+
typedef pair<int, int> pi;
22+
typedef pair<ll, ll> pll;
23+
typedef pair<ld, ld> pld;
24+
25+
typedef vector<int> vi;
26+
typedef vector<string> vs;
27+
typedef vector<char> vc;
28+
typedef vector<ld> vld;
29+
typedef vector<ll> vll;
30+
typedef vector<pi> vpi;
31+
typedef vector<pll> vpll;
32+
typedef vector<cd> vcd;
33+
34+
template <class T> using pq = priority_queue<T>;
35+
template <class T> using pqg = priority_queue<T, vector<T>, greater<T>>;
36+
37+
#define FOR(i, a, b) for (int i = a; i < (b); i++)
38+
#define F0R(i, a) for (int i = 0; i < (a); i++)
39+
#define FORd(i, a, b) for (int i = (a) - 1; i >= b; i--)
40+
#define F0Rd(i, a) for (int i = (a) - 1; i >= 0; i--)
41+
#define trav(a, x) for (auto &a : x)
42+
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)
43+
44+
#define sz(x) (int)(x).size()
45+
#define all(x) x.begin(), x.end()
46+
#define mp make_pair
47+
#define pb push_back
48+
#define fir first
49+
#define sec second
50+
#define ins insert
51+
#define lbound(a, v) lower_bound(all(a), v) - a.begin()
52+
#define ubound(a, v) upper_bound(all(a), v) - a.begin()
53+
#define gcd(a, b) __gcd(a, b)
54+
#define lcm(a, b) (a * b) / gcd(a, b)
55+
56+
template <class T> bool ckmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; }
57+
template <class T> bool ckmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
58+
59+
void __print(int x) { cerr << x; }
60+
void __print(long x) { cerr << x; }
61+
void __print(long long x) { cerr << x; }
62+
void __print(unsigned x) { cerr << x; }
63+
void __print(unsigned long x) { cerr << x; }
64+
void __print(unsigned long long x) { cerr << x; }
65+
void __print(float x) { cerr << x; }
66+
void __print(double x) { cerr << x; }
67+
void __print(long double x) { cerr << x; }
68+
void __print(char x) { cerr << '\'' << x << '\''; }
69+
void __print(const char *x) { cerr << '\"' << x << '\"'; }
70+
void __print(const string &x) { cerr << '\"' << x << '\"'; }
71+
void __print(bool x) { cerr << (x ? "true" : "false"); }
72+
73+
template <typename T, typename V> void __print(const pair<T, V> &x);
74+
template <typename T> void __print(const T &x) {
75+
int f = 0;
76+
cerr << '{';
77+
for (auto &i : x)
78+
cerr << (f++ ? ", " : ""), __print(i);
79+
cerr << "}";
80+
}
81+
template <typename T, typename V> void __print(const pair<T, V> &x) {
82+
cerr << '{';
83+
__print(x.first);
84+
cerr << ", ";
85+
__print(x.second);
86+
cerr << '}';
87+
}
88+
void _print() { cerr << "]\n"; }
89+
template <typename T, typename... V> void _print(T t, V... v) {
90+
__print(t);
91+
if (sizeof...(v))
92+
cerr << ", ";
93+
_print(v...);
94+
}
95+
96+
#ifdef DEBUG
97+
#define dbg(x...) \
98+
cerr << __func__ << ":" << __LINE__ << " [" << #x << "] = ["; \
99+
_print(x); \
100+
cerr << endl;
101+
#else
102+
#define dbg(x...)
103+
#endif
104+
105+
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
106+
107+
struct custom_hash {
108+
size_t operator()(uint64_t x) const {
109+
x ^= rng();
110+
return x ^ (x >> 16);
111+
}
112+
};
113+
114+
const int MOD = 1000000007;
115+
const char nl = '\n';
116+
const int MX = 100001;
117+
118+
void solve() {
119+
int n, m;
120+
cin >> n >> m;
121+
vi a(n);
122+
FOR(i, 0, n) cin >> a[i];
123+
vi b(m);
124+
FOR(i, 0, m) cin >> b[i];
125+
126+
if (m * 2 > n) {
127+
cout << "NO" << nl;
128+
return;
129+
}
130+
131+
sort(all(a));
132+
sort(all(b));
133+
134+
vi lessCount(m), moreCount(m);
135+
for (int i = 0; i < m; i++) {
136+
int lc = lower_bound(all(a), b[i]) - a.begin();
137+
int uc = n - lc;
138+
lessCount[i] = lc;
139+
moreCount[i] = uc;
140+
}
141+
142+
// lessCount will always decrease as we move right
143+
// we want to minimize our rightCount use
144+
for (int i = 0; i < m; i++) {
145+
int remLeft = lessCount[i] - i;
146+
int remRight = moreCount[i] - (m - i - 1);
147+
if (remLeft <= 0 || remRight <= 0) {
148+
cout << "NO" << nl;
149+
return;
150+
}
151+
}
152+
153+
cout << "YES" << nl;
154+
}
155+
156+
int main() {
157+
cin.tie(0)->sync_with_stdio(0);
158+
cin.exceptions(cin.failbit);
159+
160+
int T = 1;
161+
cin >> T;
162+
while (T--) {
163+
solve();
164+
}
165+
166+
return 0;
167+
}

CodeForces/Contests/1113/2/C

39.1 KB
Binary file not shown.

0 commit comments

Comments
 (0)