Submission #65892217


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int H, W, N;
cin >> H >> W >> N;
vector<vector<int>> row(H+1), col(W+1);
for(int i = 0; i < N; i++){
int x, y;
cin >> x >> y;
row[x].push_back(y);
col[y].push_back(x);
}
int Q;
cin >> Q;
vector<bool> row_deleted(H+1,false), col_deleted(W+1,false);
while(Q--){
int t, v;
cin >> t >> v;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include <bits/stdc++.h>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int H, W, N;
    cin >> H >> W >> N;
    vector<vector<int>> row(H+1), col(W+1);
    for(int i = 0; i < N; i++){
        int x, y;
        cin >> x >> y;
        row[x].push_back(y);
        col[y].push_back(x);
    }
    int Q;
    cin >> Q;
    vector<bool> row_deleted(H+1,false), col_deleted(W+1,false);
    while(Q--){
        int t, v;
        cin >> t >> v;
        if(t == 1){
            if(row_deleted[v]){
                cout << 0 << "\n";
            } else {
                long long cnt = 0;
                for(int y: row[v]){
                    if(!col_deleted[y]) cnt++;
                }
                cout << cnt << "\n";
                row_deleted[v] = true;
                row[v].clear();
            }
        } else {
            if(col_deleted[v]){
                cout << 0 << "\n";
            } else {
                long long cnt = 0;
                for(int x: col[v]){
                    if(!row_deleted[x]) cnt++;
                }
                cout << cnt << "\n";
                col_deleted[v] = true;
                col[v].clear();
            }
        }
    }
    return 0;
}

Submission Info

Submission Time
Task D - Garbage Removal
User OYU__0YU
Language C++ 20 (gcc 12.2)
Score 400
Code Size 1293 Byte
Status AC
Exec Time 102 ms
Memory 25188 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 40
Set Name Test Cases
Sample sample00.txt, sample01.txt, sample02.txt
All sample00.txt, sample01.txt, sample02.txt, testcase00.txt, testcase01.txt, testcase02.txt, testcase03.txt, testcase04.txt, testcase05.txt, testcase06.txt, testcase07.txt, testcase08.txt, testcase09.txt, testcase10.txt, testcase11.txt, testcase12.txt, testcase13.txt, testcase14.txt, testcase15.txt, testcase16.txt, testcase17.txt, testcase18.txt, testcase19.txt, testcase20.txt, testcase21.txt, testcase22.txt, testcase23.txt, testcase24.txt, testcase25.txt, testcase26.txt, testcase27.txt, testcase28.txt, testcase29.txt, testcase30.txt, testcase31.txt, testcase32.txt, testcase33.txt, testcase34.txt, testcase35.txt, testcase36.txt
Case Name Status Exec Time Memory
sample00.txt AC 1 ms 3420 KiB
sample01.txt AC 1 ms 3428 KiB
sample02.txt AC 1 ms 3476 KiB
testcase00.txt AC 40 ms 9080 KiB
testcase01.txt AC 92 ms 20476 KiB
testcase02.txt AC 18 ms 9112 KiB
testcase03.txt AC 94 ms 20460 KiB
testcase04.txt AC 62 ms 15132 KiB
testcase05.txt AC 89 ms 20424 KiB
testcase06.txt AC 40 ms 8772 KiB
testcase07.txt AC 87 ms 20356 KiB
testcase08.txt AC 102 ms 25188 KiB
testcase09.txt AC 38 ms 7932 KiB
testcase10.txt AC 55 ms 14740 KiB
testcase11.txt AC 39 ms 8560 KiB
testcase12.txt AC 56 ms 14544 KiB
testcase13.txt AC 37 ms 16340 KiB
testcase14.txt AC 61 ms 19356 KiB
testcase15.txt AC 28 ms 13960 KiB
testcase16.txt AC 63 ms 19560 KiB
testcase17.txt AC 28 ms 15188 KiB
testcase18.txt AC 65 ms 19316 KiB
testcase19.txt AC 22 ms 11236 KiB
testcase20.txt AC 63 ms 19672 KiB
testcase21.txt AC 42 ms 15888 KiB
testcase22.txt AC 72 ms 19676 KiB
testcase23.txt AC 34 ms 16900 KiB
testcase24.txt AC 64 ms 19552 KiB
testcase25.txt AC 56 ms 17188 KiB
testcase26.txt AC 74 ms 19392 KiB
testcase27.txt AC 45 ms 15456 KiB
testcase28.txt AC 72 ms 19540 KiB
testcase29.txt AC 28 ms 13968 KiB
testcase30.txt AC 84 ms 19380 KiB
testcase31.txt AC 46 ms 12480 KiB
testcase32.txt AC 80 ms 19520 KiB
testcase33.txt AC 28 ms 11644 KiB
testcase34.txt AC 74 ms 19416 KiB
testcase35.txt AC 29 ms 10668 KiB
testcase36.txt AC 67 ms 19588 KiB


2025-06-03 (Tue)
19:06:30 +09:00