(UPD: 2024-12-04 14:48 UTC) Judge is not working due to Cloudflare incident. (URL) We can do nothing about it, sorry. After the incident is resolved, we will grade all submissions.

Submission #198517

#TimeUsernameProblemLanguageResultExecution timeMemory
198517ZwariowanyMarcinGrudanje (COCI19_grudanje)C++17
70 / 70
167 ms4220 KiB
#include <bits/stdc++.h> #define fi first #define se second #define mp make_pair #define ss(x) (int) x.size() #define pb push_back #define LL long long #define ld long double #define cat(x) cerr << #x << " = " << x << endl #define FOR(i, j, n) for(int i = j; i <= n; ++i) #define boost cin.tie(0), ios_base::sync_with_stdio(0); using namespace std; const int N = 100100; int n, q; char s[N]; int l[N], r[N]; int p[N]; int w[N]; int pref[N]; bool ok(int k) { for (int c = 0; c < 26; ++c) { for (int i = 1; i <= n; ++i) { pref[i] = pref[i - 1]; pref[i] += ((s[i] - 'a' == c) && w[i] > k); } for (int i = 1; i <= q; ++i) if (pref[r[i]] - pref[l[i] - 1] > 1) return 0; } return 1; } int main() { scanf ("%s", s + 1); n = strlen(s + 1); scanf ("%d", &q); for (int i = 1; i <= q; ++i) scanf ("%d %d", l + i, r + i); for (int i = 1; i <= n; ++i) { scanf ("%d", p + i); w[p[i]] = i; } int l = 0; int r = n; while (l < r) { int m = (l + r) / 2; if (ok(m)) r = m; else l = m + 1; } printf ("%d", l); return 0; }

Compilation message (stderr)

grudanje.cpp: In function 'int main()':
grudanje.cpp:39:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf ("%s", s + 1);
  ~~~~~~^~~~~~~~~~~~~
grudanje.cpp:41:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf ("%d", &q);
  ~~~~~~^~~~~~~~~~
grudanje.cpp:43:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf ("%d %d", l + i, r + i);
   ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
grudanje.cpp:45:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf ("%d", p + 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...