Submission #197525

#TimeUsernameProblemLanguageResultExecution timeMemory
197525SamAndFish (IOI08_fish)C++17
0 / 100
3052 ms4276 KiB
#include <bits/stdc++.h> using namespace std; const int N = 500005, K = 22; struct ban { int x, t; }; bool operator<(const ban& a, const ban& b) { return a.x < b.x; } int n, k, M; ban a[N]; int q[K][K]; int u[K]; int main() { scanf("%d%d%d", &n, &k, &M); for (int i = 1; i <= n; ++i) { scanf("%d%d", &a[i].x, &a[i].t); --a[i].t; } sort(a + 1, a + n + 1); for (int t = 0; t < k; ++t) { int maxu = 0; for (int i = 1; i <= n; ++i) { if (a[i].t == t) maxu = a[i].x; } for (int i = 1; i <= n; ++i) { if (a[i].x * 2 <= maxu) ++q[t][a[i].t]; } ++q[t][t]; } int ans = 0; for (int x = 1; x < (1 << k); ++x) { int qq = 0; for (int i = 0; i < k; ++i) u[i] = N; for (int i = 0; i < k; ++i) { if ((x & (1 << i))) { ++qq; for (int j = 0; j < k; ++j) { if ((x & (1 << j))) u[i] = min(u[i], q[i][j] - 1); else u[i] = min(u[i], q[i][j]); } } } int yans = 1; for (int i = 0; i < k; ++i) { if (u[i] < 0) yans = 0; else yans = (yans * 1LL * u[i]) % M; } if (qq % 2 == 1) ans = (ans + yans) % M; else ans = (ans - yans + M) % M; } printf("%d\n", ans); return 0; }

Compilation message (stderr)

fish.cpp: In function 'int main()':
fish.cpp:21:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d", &n, &k, &M);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~
fish.cpp:24:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d", &a[i].x, &a[i].t);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...