QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#443385 | #8646. Card Collection | green_gold_dog# | 0 | 1ms | 3548kb | C++23 | 4.0kb | 2024-06-15 15:24:17 | 2024-06-15 15:24:21 |
answer
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,sse,sse2,sse3,ssse3,sse4,abm,popcnt,mmx")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef complex<double> cd;
constexpr ll INF64 = 9'000'000'000'000'000'000, INF32 = 2'000'000'000, MOD = 1'000'000'007;
constexpr db PI = acos(-1);
constexpr bool IS_FILE = false, IS_TEST_CASES = false;
random_device rd;
mt19937 rnd32(rd());
mt19937_64 rnd64(rd());
template<typename T>
bool assign_max(T& a, T b) {
if (b > a) {
a = b;
return true;
}
return false;
}
template<typename T>
bool assign_min(T& a, T b) {
if (b < a) {
a = b;
return true;
}
return false;
}
template<typename T>
T square(T a) {
return a * a;
}
template<>
struct std::hash<pair<ll, ll>> {
ll operator() (pair<ll, ll> p) const {
return ((__int128)p.first * MOD + p.second) % INF64;
}
};
void solve() {
ll n, m;
cin >> n >> m;
vector<pair<ll, ll>> all(n);
map<ll, ll> maxf, minf, maxs, mins;
multiset<ll> af, as;
for (ll i = 0; i < n; i++) {
cin >> all[i].first >> all[i].second;
af.insert(all[i].first);
as.insert(all[i].second);
maxf[all[i].first] = 0;
minf[all[i].first] = INF32;
maxs[all[i].second] = 0;
mins[all[i].second] = INF32;
}
for (auto[a, b] : all) {
assign_max(maxf[a], b);
assign_min(minf[a], b);
assign_max(maxs[b], a);
assign_min(mins[b], a);
}
for (ll i = 1; i <= m; i++) {
ll a, b;
cin >> a >> b;
bool can = false;
if (maxf[a] >= b && maxs[b] >= a) {
af.erase(af.find(a));
as.erase(as.find(b));
if (maxs[b] != a || maxf[a] != b) {
af.erase(af.find(maxs[b]));
as.erase(as.find(maxf[a]));
}
if (af.empty() || (*af.rbegin() >= a && *as.rbegin() >= b)) {
can = true;
}
af.insert(a);
as.insert(b);
if (maxs[b] != a || maxf[a] != b) {
af.insert(maxs[b]);
as.insert(maxf[a]);
}
}
if (minf[a] <= b && mins[b] <= a) {
af.erase(af.find(a));
as.erase(as.find(b));
if (mins[b] != a || minf[a] != b) {
af.erase(af.find(mins[b]));
as.erase(as.find(minf[a]));
}
if (af.empty() || (*af.begin() <= a && *as.begin() <= b)) {
can = true;
}
af.insert(a);
as.insert(b);
if (mins[b] != a || minf[a] != b) {
af.insert(mins[b]);
as.insert(minf[a]);
}
}
if (can) {
cout << i << ' ';
}
}
cout << '\n';
}
int main() {
if (IS_FILE) {
freopen("", "r", stdin);
freopen("", "w", stdout);
}
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
ll t = 1;
if (IS_TEST_CASES) {
cin >> t;
}
for (ll i = 0; i < t; i++) {
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Runtime Error
Test #1:
score: 11
Accepted
time: 1ms
memory: 3548kb
input:
2 10 171631799 561094698 171631799 867698918 126573648 561094698 171631799 867698918 171631799 561094698 126573648 561094698 126573648 561094698 171631799 561094698 126573648 561094698 126573648 561094698 126573648 561094698 171631799 561094698
output:
2 3 6 10
result:
ok 4 number(s): "2 3 6 10"
Test #2:
score: 0
Runtime Error
input:
3 10 713180371 43103927 713180371 136832929 853543805 251852293 892623928 251852293 713180371 136832929 713180371 43103927 853543805 43103927 892623928 136832929 713180371 43103927 853543805 43103927 892623928 136832929 713180371 43103927 892623928 251852293
output:
result:
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Skipped
Dependency #1:
0%
Subtask #4:
score: 0
Skipped
Dependency #1:
0%