# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
345373 | _zheksenov | Marriage questions (IZhO14_marriage) | C++14 | 1598 ms | 2284 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
signed main() {
int n, m, k;
cin >> n >> m >> k;
vector<vector<int> > g;
g.resize(n + 2);
for (int i = 0; i < k; i++) {
int u, v;
cin >> u >> v;
g[u].push_back(v);
}
int ans = 0;
for (int l = 1; l <= n; l++) {
set<int> s;
int cnt = 0;
for (int r = l; r <= n; r++) {
for (auto to : g[r])
s.insert(to);
if (g[r].empty())
cnt++;
int length = r - l + 1;
if (s.size() == m && s.size() <= length - cnt) {
ans++;
}
}
}
cout << ans << "\n";
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |