-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathc.cpp
More file actions
79 lines (71 loc) · 1.77 KB
/
Copy pathc.cpp
File metadata and controls
79 lines (71 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector<int> vi;
typedef vector<vi> vii;
#define fi first
#define se second
#define pb push_back
#define forn(i,n) for(int i=0;i<(n);i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define forr(i,n) for(int i=n;i>=0;i--)
#define all(x) x.begin(), x.end()
#define sz(x) ((int)x.size())
const int MAXN = 1e5 +5;
void fio(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
void solve() {
LL d, n, s, c, f;
cin >> d >> n >> s >> c >> f;
map <pair<int,int>, string> name;
map <string,int> traffic;
map <string, pair<int,int>> iname;
map <pair<int,int>, LL> len;
vector<int> beg[n];
vector<int> end[n];
for(int i = 0; i < s; i++) {
int b, e; cin >> b >> e;
cin >> name[{b,e}];
cin >> len[{b,e}];
iname[name[{b,e}]] = {b,e};
beg[e].push_back(b);
end[b].push_back(e);
}
vector <int> path[n];
vector <int> pathlen;
for(int i = 0; i < c; i++) {
int p;
cin >> p;
pathlen.push_back(p);
for(int j = 0; j < p; j++) {
string sname; cin >> sname;
traffic[sname]++;
if(!j) path[p].push_back(iname[sname].fi);
path[p].push_back(iname[sname].se);
}
}
// solution d
cout << n << endl;
for(int i = 0; i < n; i++) {
cout << i << "\n";
vector<pair<int,string>> maxTraffic;
for(auto b: beg[i])
maxTraffic.push_back(make_pair(traffic[name[{b, i}]],name[{b, i}]));
sort(maxTraffic.begin(), maxTraffic.end());
cout<<min((size_t)1000,maxTraffic.size())<<"\n";
for(int i1=0;i1<min((size_t)1000,maxTraffic.size());i1++)
cout<<maxTraffic[maxTraffic.size()-1-i1].second<<" 1\n";
}
// solution a
// cout << "3\n0\n1\nrue-de-londres 1\n1\n2\n";
// cout << "rue-d-athenes 1\nrue-d-amsterdam 1\n2\n1\n";
// cout << "rue-de-moscou 1\n";
}
int main(){
fio();
solve();
return 0;
}