Demo entry 6662134

monokai

   

Submitted by anonymous on Nov 24, 2017 at 11:59
Language: C++. Code size: 837 Bytes.

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <fstream>
#include <string>
#include <map>
#include <vector>
using namespace std;

const int maxrow = 1000;
int times[maxrow][maxrow];

struct Map {
	map<string, int> M;
	int cnt;
	Map() { cnt = 0; M.clear(); }
	int getID(string s) {
		if(M.count(s)) return M[s];
		else {
			M[s] = cnt++;
			return cnt - 1;
		}
	}
};

Map hosts, uids;
vector<string> lists;

int main(int argc, char *argv[]) {
	ifstream input(argv[1]);
	ofstream output(argv[2]);
	string uid, host;
	memset(times, 0, sizeof(times));
	while(input >> uid >> host) {
		if(!hosts.M.count(host)) lists.emplace_back(host);
		int h = hosts.getID(host), u = uids.getID(uid);
		times[h][u]++;
	}

	int row = hosts.cnt, col = uids.cnt;

	return 0;
}

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).