Cod sursa(job #2795108)

Utilizator LuciBBadea Lucian LuciB Data 5 noiembrie 2021 23:16:47
Problema Dtcsu Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.8 kb
#include <stdio.h>
#include <unordered_map>
#include <ctype.h>
#define CARDINAL 276997
using namespace std;

FILE *fin, *fout;

unordered_map<long long, bool> h;

long long readInt() {
    long long n = 0;
    char ch;
    while(!isdigit(ch = fgetc(fin)));
    do {
        n = n * 10 + ch - '0';
    }while(isdigit(ch = fgetc(fin)));

    return n;
}

int main() {
    long long n, i, ans;
    long long x;
    fin = fopen("dtcsu.in", "r");
    for(i = 0; i < CARDINAL; i++) {
        x = readInt();
        h[x] = true;
    }
    n = readInt();
    ans = 0;
    for(i = 0; i < n; i++) {
        x = readInt();
        if(h[x] == true)
            ans++;
    }
    fclose(fin);

    fout = fopen("dtcsu.out", "w");
    fprintf(fout, "%lld", ans);
    fclose(fout);
    return 0;
}