Cod sursa(job #2315631)

Utilizator DawlauAndrei Blahovici Dawlau Data 10 ianuarie 2019 12:46:24
Problema Dtcsu Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1 kb
#include <fstream>
#include <unordered_map>

using namespace std;

class InParser {

	private:
		
		static const int buffSZ = (1 << 15);
		ifstream File;
		int buffPos;
		char buff[buffSZ];

		void _advance() {

			if (++buffPos == buffSZ) {

				File.read(buff, buffSZ);
				buffPos = 0;
			}
		}

	public:

		InParser(const char *FileName) {

			File.open(FileName);
			buffPos = buffSZ - 1;
		}

		InParser& operator >>(long long &no) {

			while (!isdigit(buff[buffPos]))
				_advance();
			no = 0;
			while (isdigit(buff[buffPos])) {

				no = no * 10 + buff[buffPos] - '0';
				_advance();
			}

			return *this;
		}
};

InParser fin("dtcsu.in");
ofstream fout("dtcsu.out");

int main() {

	unordered_map <int, bool> HashMap;

	long long Q = 276997;
	for (; Q; --Q) {

		long long no;
		fin >> no;

		HashMap[no] = true;
	}

	int cnt = 0;

	fin >> Q;
	for (; Q; --Q) {

		long long no;
		fin >> no;

		if (HashMap[no])
			++cnt;
	}

	fout << cnt;
}