Submission #57536430
Source Code Expand
// D - Cross Explosion
#include<bits/stdc++.h>
#define debug(...) fprintf(stderr, __VA_ARGS__)
using namespace std;
int n, m, q, cnt;
vector<set<int>> row, col;
void del(int x, int y)
{
cnt--;
auto it_row = row[x].find(y);
assert(it_row != row[x].end());
row[x].erase(it_row);
auto it_col = col[y].find(x);
assert(it_col != col[y].end());
col[y].erase(it_col);
// debug("(%d, %d) deleted\n", x, y);
}
int main()
{
cin >> n >> m >> q;
row.resize(n + 1), col.resize(m + 1);
for(int i = 1; i <= n; i++)
for(int j = 1; j <= m; j++) row[i].insert(j);
for(int i = 1; i <= m; i++)
for(int j = 1; j <= n; j++) col[i].insert(j);
cnt = n * m;
for(int i = 1, x, y; i <= q; i++)
{
cin >> x >> y;
auto it_row = row[x].lower_bound(y);
if(*it_row == y) del(x, y);
else
{
if(it_row != row[x].begin()) del(x, *(prev(it_row)));
if(it_row!= row[x].end()) del(x, *it_row);
auto it_col = col[y].lower_bound(x);
if(it_col != col[y].begin()) del(*(prev(it_col)), y);
if(it_col != col[y].end()) del(*it_col, y);
}
}
cout << cnt << endl;
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | D - Cross Explosion |
| User | dengstar |
| Language | C++ 17 (gcc 12.2) |
| Score | 400 |
| Code Size | 1142 Byte |
| Status | AC |
| Exec Time | 379 ms |
| Memory | 59388 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 400 / 400 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt |
| All | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 02_all_break_00.txt, 03_hack_00.txt, 03_hack_01.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00_sample_00.txt | AC | 1 ms | 3540 KiB |
| 00_sample_01.txt | AC | 1 ms | 3640 KiB |
| 00_sample_02.txt | AC | 1 ms | 3456 KiB |
| 01_random_00.txt | AC | 337 ms | 38868 KiB |
| 01_random_01.txt | AC | 232 ms | 39048 KiB |
| 01_random_02.txt | AC | 282 ms | 42456 KiB |
| 01_random_03.txt | AC | 379 ms | 42420 KiB |
| 01_random_04.txt | AC | 368 ms | 40572 KiB |
| 01_random_05.txt | AC | 336 ms | 42224 KiB |
| 01_random_06.txt | AC | 339 ms | 42396 KiB |
| 01_random_07.txt | AC | 273 ms | 42564 KiB |
| 01_random_08.txt | AC | 230 ms | 44352 KiB |
| 01_random_09.txt | AC | 348 ms | 40572 KiB |
| 01_random_10.txt | AC | 255 ms | 42924 KiB |
| 01_random_11.txt | AC | 285 ms | 41140 KiB |
| 01_random_12.txt | AC | 295 ms | 40924 KiB |
| 01_random_13.txt | AC | 325 ms | 41076 KiB |
| 01_random_14.txt | AC | 300 ms | 40984 KiB |
| 01_random_15.txt | AC | 316 ms | 40840 KiB |
| 01_random_16.txt | AC | 287 ms | 40608 KiB |
| 01_random_17.txt | AC | 316 ms | 43812 KiB |
| 01_random_18.txt | AC | 333 ms | 40648 KiB |
| 01_random_19.txt | AC | 282 ms | 41064 KiB |
| 02_all_break_00.txt | AC | 189 ms | 40644 KiB |
| 03_hack_00.txt | AC | 160 ms | 59388 KiB |
| 03_hack_01.txt | AC | 161 ms | 59376 KiB |