#include "bits/stdc++.h"
using namespace std;
void abc() {cout << endl;}
template <typename T, typename ...U> void abc(T a, U ...b) {
cout << a << ' ', abc(b...);
}
template <typename T> void printv(T l, T r) {
while (l != r) cout << *l << " \n"[++l == r];
}
template <typename A, typename B> istream& operator >> (istream& o, pair<A, B> &a) {
return o >> a.first >> a.second;
}
template <typename A, typename B> ostream& operator << (ostream& o, pair<A, B> a) {
return o << '(' << a.first << ", " << a.second << ')';
}
template <typename T> ostream& operator << (ostream& o, vector<T> a) {
bool is = false;
for (T i : a) {o << (is ? ' ' : '{'), is = true, o << i;}
return o << '}';
}
#ifdef local
#define test(args...) abc("[" + string(#args) + "]", args)
#else
#define test(args...) void(0)
#endif
using ll = long long;
int col[300005];
vector<int> adj[300005];
multiset<set<int>> cur[300005][6];
ll total = 0;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
// freopen("", "r", stdin);
// freopen("", "w", stdout);
int n, m, k; cin >> n >> m >> k;
for (int i = 1; i <= n; i++) {
cin >> col[i];
cur[i][1].insert({col[i]});
}
for (int i = 1; i <= m; i++) {
int a, b; cin >> a >> b;
adj[a].push_back(b);
adj[b].push_back(a);
}
for (int len = 2; len <= k; len++) {
for (int i = 1; i <= n; i++) {
int curcol = col[i];
for (auto nxt : adj[i]) {
for (auto st : cur[nxt][len - 1]) {
if (st.count(curcol) == 0) {
set<int> tmp = st;
tmp.insert(curcol);
cur[i][len].insert(tmp);
total++;
}
}
}
}
}
cout << total;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
52 ms |
92240 KB |
Output is correct |
2 |
Correct |
47 ms |
91944 KB |
Output is correct |
3 |
Correct |
50 ms |
91904 KB |
Output is correct |
4 |
Correct |
47 ms |
91824 KB |
Output is correct |
5 |
Correct |
45 ms |
91892 KB |
Output is correct |
6 |
Correct |
46 ms |
92644 KB |
Output is correct |
7 |
Correct |
45 ms |
92544 KB |
Output is correct |
8 |
Correct |
49 ms |
91896 KB |
Output is correct |
9 |
Correct |
46 ms |
91984 KB |
Output is correct |
10 |
Correct |
50 ms |
91796 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3057 ms |
770668 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
52 ms |
92240 KB |
Output is correct |
2 |
Correct |
47 ms |
91944 KB |
Output is correct |
3 |
Correct |
50 ms |
91904 KB |
Output is correct |
4 |
Correct |
47 ms |
91824 KB |
Output is correct |
5 |
Correct |
45 ms |
91892 KB |
Output is correct |
6 |
Correct |
46 ms |
92644 KB |
Output is correct |
7 |
Correct |
45 ms |
92544 KB |
Output is correct |
8 |
Correct |
49 ms |
91896 KB |
Output is correct |
9 |
Correct |
46 ms |
91984 KB |
Output is correct |
10 |
Correct |
50 ms |
91796 KB |
Output is correct |
11 |
Execution timed out |
3057 ms |
770668 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
50 ms |
91836 KB |
Output is correct |
2 |
Execution timed out |
3092 ms |
774556 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |