Submission #447945

#TimeUsernameProblemLanguageResultExecution timeMemory
447945parsabahramiFish (IOI08_fish)C++17
0 / 100
293 ms16852 KiB
/* I do it for the glory */ #include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<int, int> pii; #define SZ(x) (int) x.size() #define F first #define S second const int N = 5e5 + 10; int F[N], lst[N], ord[N], A[N], g[N], k, md, n; void upd(int p) { for (; p < N; p += p & -p) F[p] = 2ll * F[p] % md; } int get(int p) { int ret = 1; for (; p; p -= p & -p) ret = 1ll * F[p] * ret % md; return ret; } int main() { scanf("%d%d%d", &n, &k, &md); for (int i = 1; i <= n; i++) { scanf("%d%d", &A[i], &g[i]), ord[i] = i; } sort(ord + 1, ord + n + 1, [&] (int i, int j) { return A[i] < A[j]; }); for (int _ = n; _; _--) { int i = ord[_]; if (!lst[g[i]]) lst[g[i]] = _; } int ret = 0; fill(F, F + N, 1); for (int j = 1, pt = 0; j <= n; j++) { int i = ord[j]; while (A[ord[pt + 1]] * 2 <= A[i]) pt++, upd(lst[g[ord[pt]]]); if (j != lst[g[i]]) continue; ret = (ret + get(j)) % md; } printf("%d\n", ret); return 0; }

Compilation message (stderr)

fish.cpp: In function 'int main()':
fish.cpp:28:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |     scanf("%d%d%d", &n, &k, &md);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
fish.cpp:30:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |         scanf("%d%d", &A[i], &g[i]), ord[i] = i;
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~
#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...