Skip to content

Instantly share code, notes, and snippets.

@C10udburst
Created August 30, 2022 15:07
Show Gist options
  • Save C10udburst/6aa8ea8b49b0d02a9fa7514cd797fd6a to your computer and use it in GitHub Desktop.
Save C10udburst/6aa8ea8b49b0d02a9fa7514cd797fd6a to your computer and use it in GitHub Desktop.
WP test poziomujący
#define IO_SPEED 1
#include <bits/stdc++.h>
#define MODULO 1000000000
using namespace std;
int main() {
#if IO_SPEED>0
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);
#endif
int n;
cin >> n;
long long res = 1;
// for (int i = 1; i <= n; i++) {
// res = ( (i % MODULO) * (res % MODULO) ) % MODULO;
// if (res != 0) {
// cout << i << "! = " << res << endl;
// }
// }
if (n > 39) { // dla n > 39 wszystkie silnie sa wieksze niz MODULO
cout << 0;
return 0;
}
while (n > 1) {
res = ( (n-- % MODULO) * (res % MODULO) ) % MODULO;
}
cout << res;
return 0;
}
#define IO_SPEED 1
#include <bits/stdc++.h>
using namespace std;
int main() {
#if IO_SPEED>0
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);
#endif
string s;
char cmd = 0;
cin >> s;
cin >> cmd;
char a, b;
int n;
while (cmd != 'N') {
switch (cmd) {
case 'Z': {
cin >> a >> b;
for (int i = 0; i < s.length(); i++) {
if (s[i] == a) s[i] = b;
}
break;
}
case 'D': {
cin >> a;
s.push_back(a);
break;
}
case 'U': {
cin >> n;
s.erase(s.length() - n, n);
break;
}
}
cin >> cmd;
}
cout << s;
return 0;
}
#define IO_SPEED 1
#include <bits/stdc++.h>
using namespace std;
struct range {
long long min;
long long max;
};
range& operator+= (range& a, range& b) {
a.min = min(a.min, b.min);
a.max = max(a.max, b.max);
return a;
}
bool disjoint(range& a, range& b) {
return !(
( a.max >= (b.min - 1) ) && ( b.max >= (a.min - 1) )
);
}
istream& operator>>(istream& stream, range& r) {
cin >> r.min >> r.max;
return stream;
}
int main() {
#if IO_SPEED>0
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);
#endif
int n;
cin >> n;
vector<range> ranges;
ranges.push_back(range());
cin >> ranges[0];
n--;
range r;
bool did_join = false;
while(n-- > 0) {
r = range();
cin >> r;
did_join = false;
for (size_t i = 0; i < ranges.size(); i++) {
if (disjoint(r, ranges[i])) continue;
ranges[i] += r;
did_join = true;
break;
}
if (!did_join) {
ranges.push_back(r);
}
}
cout << ranges.size();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment