Submission #93421

#TimeUsernameProblemLanguageResultExecution timeMemory
93421inomMarriage questions (IZhO14_marriage)C++14
36 / 100
1584 ms2936 KiB
#include<bits/stdc++.h> #define fi first #define se second #define pb push_back #define int long long #define sz(c) (int)(c).size() #define all(c) (c).begin(), (c).end() #define rall(c) (c).rbegin(), (c).rend() using namespace std; const int N = 30030; int TN = 1; int n, m, k; int cnt, ans; int us[N][55]; bool flag = false; vector<int> verr[N]; void rec(int a, int b, int cnt, int pos) { if (a > b) { if (cnt >= m) { flag = true; return; } else { return; } } if (cnt >= m) { flag = true; return; } for (int i: verr[a]) { if (!us[pos][i]) { us[pos][i] = 1; rec(a + 1, b, cnt + 1, pos); us[pos][i] = 0; } } rec(a + 1, b, cnt, pos); } void solve() { scanf("%lld %lld %lld", &n, &m, &k); for (int i = 1; i <= k; i++) { int x, y; scanf("%lld %lld", &x, &y); verr[x].push_back(y); } int pos = 0; for (int i = 1; i <= n; i++) { int l = i, r = n; while (l + 1 < r) { int mid = (l + r) >> 1; if (mid - i + 1 < m) { l = mid + 1; continue; } flag = false; cnt = 0; pos++; rec(i, mid, cnt, pos); if (flag) { r = mid; } else { l = mid + 1; } } flag = false; cnt = 0; pos++; rec(i, r, cnt, pos); if (!flag) { continue; } flag = false; cnt = 0; pos++; rec(i, l, cnt, pos); if (flag) { ans += (n - l + 1); } else { ans += (n - r + 1); } // cout << i << " " << l << " " << r << "\n"; /*for (int r = l + m - 1; r <= n; r++) { flag = false; cnt = 0; rec(l, r, cnt, ans + 1); ans += flag; if (flag) { ans += (n - r); break; } }*/ } printf("%lld\n", ans); return; } signed main() { // in; out; // cin >> TN; while (TN--) { solve(); } return 0; }

Compilation message (stderr)

marriage.cpp: In function 'void solve()':
marriage.cpp:45:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld %lld %lld", &n, &m, &k);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
marriage.cpp:48:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld %lld", &x, &y); verr[x].push_back(y);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...