QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#143233 | #6754. Selection | Kidding_Ma | WA | 2ms | 3536kb | C++20 | 6.2kb | 2023-08-20 22:41:02 | 2023-08-20 22:41:03 |
Judging History
answer
#include "bits/stdc++.h"
using namespace std;
using i64 = long long;
using i128 = __int128;
namespace cpstd {
#define range(a) begin(a), end(a)
template <class T>
T max(const vector<T> &a) {
return *std::max_element(a.begin(), a.end());
}
template <class T>
T min(const vector<T> &a) {
return *std::min_element(a.begin(), a.end());
}
template <class T>
struct Fenwick {
int n;
std::vector<T> a;
Fenwick(const int &n = 0) : n(n), a(n, T()) {}
void modify(int i, T x) {
for (i++; i <= n; i += i & -i) {
a[i - 1] += x;
}
}
T get(int i) {
T res = T();
for (; i > 0; i -= i & -i) {
res += a[i - 1];
}
return res;
}
T sum(int l, int r) { // [l, r)
return get(r) - get(l);
}
T kth(T k) {
int x = 0;
for (int i = 1 << std::__lg(n); i; i >>= 1) {
if (x + i <= n && k >= a[x + i - 1]) {
x += i;
k -= a[x - 1];
}
}
return x;
}
};
template <class T>
T exgcd(T a, T b, T &x, T &y) {
if (!b) {
x = 1, y = 0;
return a;
}
T g = exgcd(b, a % b, y, x);
y -= a / b * x;
return g;
}
template <class T>
T floor_sum(T n, T m, T a, T b) {
T ans = 0;
if (a < 0) {
T a2 = (a % m + m) % m;
ans -= n * (n - 1) / 2 * ((a2 - a) / m);
a = a2;
}
if (b < 0) {
T b2 = (b % m + m) % m;
ans -= n * ((b2 - b) / m);
b = b2;
}
while (1) {
if (a >= m) {
ans += n * (n - 1) / 2 * (a / m);
a %= m;
}
if (b >= m) {
ans += n * (b / m);
b %= m;
}
T y_max = a * n + b;
if (y_max < m) {
break;
}
n = y_max / m;
b = y_max % m;
swap(m, a);
}
return ans;
}
template <class T, class U1, class U2>
T power(T a, U1 b, U2 p) {
T res = 1;
for (; b; b >>= 1, a = a * a % p) {
if (b & 1) {
res = res * a % p;
}
}
return res;
}
template <class T, class U>
T power(T a, U b) {
T res = 1;
for (; b; b >>= 1, a = a * a) {
if (b & 1) {
res = res * a;
}
}
return res;
}
__int128 abs(const __int128 &v) {
return (v < 0 ? -v : v);
}
std::mt19937 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());
istream &operator>>(istream &is, __int128 &v) {
std::string s;
is >> s;
v = 0;
for (auto &si : s) {
v = v * 10 + si - '0';
}
return is;
}
ostream &operator<<(ostream &os, const __int128 &v) {
if (v <= 1000000000000000000) {
return os << (long long) (v);
}
return os << (long long) (v / 1000000000000000000) << std::setw(18) << std::setfill('0') << (long long) (v % 1000000000000000000);
}
template <class T>
T crt(const vector<T> &r, const vector<T> &m) {
int n = r.size();
T r0 = 0, m0 = 1;
for (int i = 0; i < n; i++) {
T m1 = m[i];
T r1 = r[i] % m1;
if (r1 < 0) {
r1 += m1;
}
if (m0 < m1) {
std::swap(r0, r1);
std::swap(m0, m1);
}
if (!(m0 % m1)) {
if (r0 % m1 != r1) {
return -1;
}
continue;
}
T x, y;
T g = exgcd(m0, m1, x, y);
if ((r1 - r0) % g) {
return -1;
}
T u1 = m1 / g;
r0 += (r1 - r0) / g % u1 * x % u1 * m0;
m0 *= u1;
if (r0 < 0) {
r0 += m0;
}
}
return r0;
}
constexpr int B = 777;
constexpr long long P = 100000000000031;
long long *p;
void initHash(int N) {
p = new long long [N + 1];
for (int i = 0; i <= N; i++) {
p[i] = 0;
}
p[0] = 1;
for (int i = 1; i <= N; i++) {
p[i] = p[i - 1] * B % P;
}
}
struct StringHash {
std::vector<long long> h;
StringHash() : h(1) {}
void push_back(char ch) {
h.push_back((h.back() * B + ch) % P);
}
long long get(int l, int r) { // [l, r)
return (h[r] + __int128(h[l]) * (P - p[r - l])) % P;
}
};
struct UnionFind {
int n;
std::vector<int> f, sz;
UnionFind(const int &n = 0) : n(n), f(n), sz(n, 1) {
std::iota(f.begin(), f.end(), 0);
}
int get(int x) {
while (x != f[x]) {
x = f[x] = f[f[x]];
}
return x;
}
bool unite(int x, int y) {
x = get(x), y = get(y);
if (x != y) {
f[y] = x;
sz[x] += sz[y];
return 1;
}
return 0;
}
bool united(int x, int y) {
return get(x) == get(y);
}
int size(int x) {
x = get(x);
return sz[x];
}
};
}
using namespace cpstd;
void solve() {
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, m, q;
cin >> n >> m >> q;
vector<array<int, 2>> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i][0] >> a[i][1];
}
while (q--) {
int o;
cin >> o;
if (o == 1) {
int x, y;
cin >> x >> y;
x--;
a[x][1] = y;
} else {
int x;
cin >> x;
x--;
int ok = 0;
int mx = 0;
for (int i = 0; i < n; i++) {
if (a[i][1] == 1) {
ok = 1;
mx = max(mx, a[i][0]);
}
}
if (a[x][0] == mx && a[x][1] == 1) {
cout << "1\n";
} else {
int tm = m;
if (ok) {
tm = m - 1;
}
for (int i = 0; i < n; i++) {
if (i != x) {
if (a[i][0] > a[x][0]) {
tm--;
}
}
}
cout << (tm >= 1 ? 1 : 0) << '\n';
}
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3464kb
input:
3 2 3 3 0 1 1 2 0 2 2 1 2 0 2 2
output:
1 0
result:
ok 2 number(s): "1 0"
Test #2:
score: 0
Accepted
time: 2ms
memory: 3504kb
input:
1000 1 1000 617 0 199 0 776 0 536 1 258 0 311 1 579 0 844 0 356 1 587 0 564 0 782 0 37 1 717 1 612 1 245 1 444 1 750 0 52 1 92 1 741 0 266 1 71 1 189 1 419 1 580 1 585 1 268 1 255 0 490 1 70 1 497 1 829 1 469 1 641 0 929 1 379 1 507 0 474 1 407 0 221 1 985 0 815 1 217 0 445 1 386 0 132 0 154 0 736 1...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 470 numbers
Test #3:
score: 0
Accepted
time: 2ms
memory: 3532kb
input:
1000 1 1000 541 1 236 1 583 1 99 0 324 0 107 0 459 0 854 0 772 0 426 1 717 1 806 0 335 0 503 0 860 0 463 1 306 1 813 0 947 1 989 0 736 1 713 0 65 1 222 0 428 0 680 0 652 1 681 1 661 0 595 1 474 1 70 1 641 1 688 0 591 0 20 1 330 1 563 0 38 1 638 1 391 1 979 1 488 0 829 0 956 1 395 1 694 0 669 0 567 0...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 516 numbers
Test #4:
score: -100
Wrong Answer
time: 2ms
memory: 3536kb
input:
1000 50 1000 950 0 163 0 276 0 422 1 449 0 81 0 245 1 995 1 908 1 466 0 123 0 848 1 749 0 370 1 86 1 299 1 384 0 570 1 678 0 713 0 360 0 737 0 627 0 60 1 250 1 88 1 915 1 145 0 863 0 925 1 742 0 409 1 858 1 441 0 803 0 811 1 575 0 47 0 271 1 107 1 431 0 677 1 704 0 340 0 160 0 856 1 176 0 488 1 832 ...
output:
0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 ...
result:
wrong answer 87th numbers differ - expected: '1', found: '0'