# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
337282 | boykut | Marriage questions (IZhO14_marriage) | C++14 | 5 ms | 384 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;
const int MAXN = 101, MAXM = 51;
const int MAXK = MAXN * MAXM;
int dp[MAXN][MAXM], a[MAXK], b[MAXK], n, m, k;
bool can (int l, int r) {
int mas[m + 1];
fill (mas, mas + 1 + m, 0);
for (int i = l; i <= r; i++) {
for (int j = 1; j <= m; j++) {
mas[j] |= dp[i][j];
}
}
if (count(mas, mas + 1 + m, 0) == 1) {
//cout << "(" << l << ' ' << r << "), ";
return true;
} else return false;
}
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m >> k;
if (!(n <= 100 && m <= 50))
return 0;
for (int i = 0; i < k; i++) {
cin >> a[i] >> b[i];
dp[a[i]][b[i]] = 1;
}
int ans = 0;
for (int l = 1; l <= n; l++) {
for (int r = l + m - 1; r <= n; r++) {
if (can(l, r))
ans++;
}
}
cout << ans << '\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |