QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#421403 | #6754. Selection | Fugeg# | WA | 23ms | 3640kb | C++17 | 1.7kb | 2024-05-25 17:55:47 | 2024-05-25 17:55:51 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e3 + 10, M = 4e5;
ll n, m, q;
struct node
{
ll v, sex, f, id;
} e[N], e1[N];
bool cmp2(node a, node b)
{
return a.v > b.v;
}
void solve()
{
cin >> n >> m >> q;
for (int i = 1; i <= n; i++)
{
cin >> e[i].v >> e[i].sex;
e[i].id = i;
}
ll maxx = -1, f = -1;
for (int i = 1; i <= n; i++)
{
e1[i].sex = e[i].sex;
e1[i].v = e[i].v;
e1[i].id = e[i].id;
e1[i].f = 0;
if (e1[i].sex == 1)
{
maxx = max(maxx, e1[i].v);
f = i;
}
}
if (maxx == -1)
{
sort(e1 + 1, e1 + n + 1, cmp2);
for (int i = 1; i <= m; i++)
{
e1[i].f = 1;
}
}
else
{
e[f].f = 1;
sort(e1 + 1, e1 + n + 1, cmp2);
for (int i = 1; i <= m - 1; i++)
{
e[e1[i].id].f = 1;
}
}
while (q--)
{
int op;
cin >> op;
if (op == 1)
{
int a, b;
cin >> a >> b;
e[a].sex = b;
ll maxx = -1, f = -1;
for (int i = 1; i <= n; i++)
{
e[i].f = 0;
e1[i].sex = e[i].sex;
e1[i].v = e[i].v;
e1[i].id = e[i].id;
e1[i].f = 0;
if (e1[i].sex == 1)
{
maxx = max(maxx, e1[i].v);
f = i;
}
}
if (maxx == -1)
{
sort(e1 + 1, e1 + n + 1, cmp2);
for (int i = 1; i <= m; i++)
{
e[e1[i].id].f = 1;
}
}
else
{
e[f].f = 1;
sort(e1 + 1, e1 + n + 1, cmp2);
for (int i = 1; i <= m - 1; i++)
{
e[e1[i].id].f = 1;
}
}
}
else
{
int x;
cin >> x;
if (e[x].f)
cout << 1 << endl;
else
cout << 0 << endl;
}
}
}
int main()
{
std::ios::sync_with_stdio(0);
std::cin.tie(0);
std::cout.tie(0);
int t = 1;
// cin >> t;
while (t--)
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3560kb
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: -100
Wrong Answer
time: 23ms
memory: 3640kb
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 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:
wrong answer 69th numbers differ - expected: '1', found: '0'