Submission #62275989


Source Code Expand

Copy
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
int n,q;
cin >> n >> q;
int cnt=0;
vector<int>freq(n+1,1);
map<int,int>mp;
for(int i=1;i<=n;i++){
mp[i]=i;
}
while(q>0){
int type;
cin >> type;
if(type==1){
int p,h;
cin >> p >> h;
freq[mp[p]]--;
if(freq[mp[p]]==1){
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include<bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
    int n,q;
    cin >> n >> q;
    int cnt=0;
    vector<int>freq(n+1,1);
    map<int,int>mp;
    for(int i=1;i<=n;i++){
        mp[i]=i;
    }
    while(q>0){
        int type;
        cin >> type;
        if(type==1){
            int p,h;
            cin >> p >> h;
            freq[mp[p]]--;
            if(freq[mp[p]]==1){
                cnt--;
            }
            mp[p]=h;
            freq[mp[p]]++;
            if(freq[mp[p]]==2){
                cnt++;
            }
        }
        else {
            cout << cnt << endl;
        }
        q--;
    }
    return 0;
}

Submission Info

Submission Time
Task C - Pigeonhole Query
User shivam_satyam
Language C++ 20 (gcc 12.2)
Score 300
Code Size 702 Byte
Status AC
Exec Time 836 ms
Memory 73480 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 2
AC × 39
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt
All 00_sample_00.txt, 00_sample_01.txt, 01_test_00.txt, 01_test_01.txt, 01_test_02.txt, 01_test_03.txt, 01_test_04.txt, 01_test_05.txt, 01_test_06.txt, 01_test_07.txt, 01_test_08.txt, 01_test_09.txt, 01_test_10.txt, 01_test_11.txt, 01_test_12.txt, 01_test_13.txt, 01_test_14.txt, 01_test_15.txt, 01_test_16.txt, 01_test_17.txt, 01_test_18.txt, 01_test_19.txt, 01_test_20.txt, 01_test_21.txt, 01_test_22.txt, 01_test_23.txt, 01_test_24.txt, 01_test_25.txt, 01_test_26.txt, 01_test_27.txt, 01_test_28.txt, 01_test_29.txt, 01_test_30.txt, 01_test_31.txt, 01_test_32.txt, 01_test_33.txt, 01_test_34.txt, 01_test_35.txt, 01_test_36.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3460 KB
00_sample_01.txt AC 1 ms 3652 KB
01_test_00.txt AC 1 ms 3400 KB
01_test_01.txt AC 1 ms 3572 KB
01_test_02.txt AC 2 ms 3628 KB
01_test_03.txt AC 11 ms 4180 KB
01_test_04.txt AC 133 ms 10260 KB
01_test_05.txt AC 160 ms 3492 KB
01_test_06.txt AC 308 ms 3412 KB
01_test_07.txt AC 525 ms 73280 KB
01_test_08.txt AC 297 ms 3636 KB
01_test_09.txt AC 568 ms 73280 KB
01_test_10.txt AC 285 ms 3568 KB
01_test_11.txt AC 608 ms 73476 KB
01_test_12.txt AC 274 ms 3524 KB
01_test_13.txt AC 638 ms 73372 KB
01_test_14.txt AC 261 ms 3568 KB
01_test_15.txt AC 660 ms 73480 KB
01_test_16.txt AC 246 ms 3528 KB
01_test_17.txt AC 704 ms 73320 KB
01_test_18.txt AC 231 ms 3528 KB
01_test_19.txt AC 739 ms 73284 KB
01_test_20.txt AC 216 ms 3548 KB
01_test_21.txt AC 774 ms 73292 KB
01_test_22.txt AC 199 ms 3532 KB
01_test_23.txt AC 802 ms 73320 KB
01_test_24.txt AC 182 ms 3496 KB
01_test_25.txt AC 836 ms 73320 KB
01_test_26.txt AC 165 ms 3504 KB
01_test_27.txt AC 822 ms 73280 KB
01_test_28.txt AC 247 ms 3528 KB
01_test_29.txt AC 711 ms 73252 KB
01_test_30.txt AC 247 ms 3528 KB
01_test_31.txt AC 702 ms 73304 KB
01_test_32.txt AC 248 ms 3512 KB
01_test_33.txt AC 705 ms 73336 KB
01_test_34.txt AC 689 ms 73276 KB
01_test_35.txt AC 707 ms 73480 KB
01_test_36.txt AC 484 ms 73416 KB


2025-03-18 (Tue)
20:11:35 +00:00