QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#597274 | #9424. Stop the Castle 2 | ucup-team4906# | WA | 177ms | 7392kb | C++14 | 3.8kb | 2024-09-28 17:27:06 | 2024-09-28 17:27:07 |
Judging History
answer
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define N 100010
int n, m, k;
int xc[N], yc[N], xo[N], yo[N];
map<int, set<pair<int, int>>>X, Y;
vector<int>V0, V1, V2;
vector<int>answer;
bool vst[N];
int ans;
void init()
{
cin >> n >> m >> k;
for (int i = 1; i <= n; i ++)
{
cin >> xc[i] >> yc[i];
X[xc[i]].insert({yc[i], i});
Y[yc[i]].insert({xc[i], i});
}
for (int i = 1; i <= m; i ++)
{
cin >> xo[i] >> yo[i];
X[xo[i]].insert({yo[i], -i});
Y[yo[i]].insert({xo[i], -i});
}
}
void calcans()
{
for (int i = 1; i <= n; i ++)
{
int x = xc[i], y = yc[i];
auto it = X[x].lower_bound({y + 1, -1e9});
if (it != X[x].end() && (*it).second > 0)
{
// cout << "EEE:" << i << ' ' << (*it).second << " " << x << ' ' << y << endl;
ans ++;
}
it = Y[y].lower_bound({x + 1, -1e9});
if (it != Y[y].end() && (*it).second > 0)
{
// cout << "EEE:" << i << ' ' << (*it).second << endl;
ans ++;
}
}
}
void calc0()
{
for (int i = 1; i <= m; i ++)
{
int x = xo[i], y = yo[i];
auto itr1 = X[x].lower_bound({y + 1, -1e9}), itl1 = X[x].lower_bound({y, -1e9});
if (!(itr1 == X[x].end() || itl1 == X[x].begin()))
{
itl1 --;
if ((*itl1).second > 0 && (*itr1).second > 0) continue;
}
auto itr2 = Y[y].lower_bound({x + 1, -1e9}), itl2 = Y[y].lower_bound({x, -1e9});
if (!(itr2 == Y[y].end() || itl2 == Y[y].begin()))
{
itl2 --;
if ((*itl2).second > 0 && (*itr2).second > 0) continue;
}
vst[i] = 1;
V0.push_back(i); X[xo[i]].erase({yo[i], -i}); Y[yo[i]].erase({xo[i], -i});
}
}
void calc1()
{
for (int i = 1; i <= m; i ++) if (!vst[i])
{
int num = 0;
int x = xo[i], y = yo[i];
auto itr1 = X[x].lower_bound({y + 1, -1e9}), itl1 = X[x].lower_bound({y, -1e9});
if (!(itr1 == X[x].end() || itl1 == X[x].begin()))
{
itl1 --;
if ((*itl1).second > 0 && (*itr1).second > 0) num ++;
}
auto itr2 = Y[y].lower_bound({x + 1, -1e9}), itl2 = Y[y].lower_bound({x, -1e9});
if (!(itr2 == Y[y].end() || itl2 == Y[y].begin()))
{
itl2 --;
if ((*itl2).second > 0 && (*itr2).second > 0) num ++;
}
if (num == 2)continue;
vst[i] = 1;
V1.push_back(i); X[xo[i]].erase({yo[i], -i}); Y[yo[i]].erase({xo[i], -i});
}
}
void calc2()
{
for (int i = 1; i <= m; i ++) if (!vst[i]){V2.push_back(i);}
}
void sol()
{
init();
calcans();
// cout << "??:" << ans << endl;
// cout << "GG:" << V0.back() << endl;
calc0();
calc1();
calc2();
while (k --)
{
if (!V0.empty())
{
int x = V0.back();
answer.push_back(x);
V0.pop_back();
continue;
}
if (!V1.empty())
{
int x = V1.back();
answer.push_back(x);
ans ++;
V1.pop_back();
continue;
}
int x = V2.back();
V2.pop_back();
answer.push_back(x);
ans += 2;
}
// cout << "ANS:" << endl;
cout << ans << '\n';
for (int x : answer)cout << x << ' '; cout << '\n';
X.clear(); Y.clear();
for (int i = 1; i <= m; i ++) vst[i] = 0;
V0.clear(); V1.clear(); V2.clear();
answer.clear();
ans = 0;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int T; cin >> T;
while (T --) sol();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3624kb
input:
3 8 6 4 1 3 2 1 2 6 4 1 4 7 6 1 6 3 6 6 2 3 3 1 4 3 4 6 5 2 6 4 3 2 1 10 12 10 10 10 11 1 4 1 5 1 3 2 1 1 2 1 2 2 2 3
output:
4 5 3 6 2 2 2 0 3 2
result:
ok ok 3 cases (3 test cases)
Test #2:
score: -100
Wrong Answer
time: 177ms
memory: 7392kb
input:
1224 11 17 14 7 3 4 2 8 13 3 15 3 4 5 11 10 2 3 3 8 6 7 11 2 3 10 4 1 3 12 1 2 5 11 9 11 6 11 10 8 15 1 5 9 14 4 11 1 6 10 7 7 6 11 4 8 4 1 11 18 3 2 14 8 2 14 13 13 9 12 14 12 5 6 8 1 10 5 8 6 8 9 6 6 7 5 12 11 6 11 13 5 1 10 7 6 14 5 6 15 2 4 11 1 1 6 4 14 14 13 9 9 3 10 12 7 5 8 13 9 14 1 9 8 4 9...
output:
7 17 16 15 13 12 11 10 9 8 7 6 5 4 3 15 3 2 0 6 5 4 3 0 9 8 7 6 5 4 3 2 11 3 1 8 3 2 1 0 12 11 10 9 8 7 6 5 4 3 2 1 1 12 11 10 9 7 6 5 8 19 18 17 1 8 7 6 5 4 3 2 1 7 8 6 10 15 14 13 1 20 19 18 17 16 15 14 13 12 11 10 0 1 1 3 2 0 7 6 5 7 14 13 12 11 8 2 14 13 12 11 10 4 8 7 6 5 4 3 ...
result:
wrong answer Jury has better answer. Participant's answer is 19 while jury's answer is 18 (test case 254)