(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 #481171

#TimeUsernameProblemLanguageResultExecution timeMemory
481171rainboyGrudanje (COCI19_grudanje)C11
56 / 70
41 ms2972 KiB
#include <stdio.h> #include <string.h> #define N 100000 #define Q 100000 #define A 26 int min(int a, int b) { return a < b ? a : b; } int max(int a, int b) { return a > b ? a : b; } char cc[N + 1]; int pp[N], ll[N], n; int solve(int k) { static int prev[A]; int i, j; memset(prev, -1, A * sizeof *prev); for (j = 0, i = -1; j < n; j++) { int a; if (pp[j] <= k) continue; a = cc[j] - 'a'; i = max(i, prev[a]); prev[a] = j; if (ll[j] <= i) return 0; } return 1; } int main() { int q, i, j, p, lower, upper; scanf("%s%d", cc, &q), n = strlen(cc); for (i = 0; i < n; i++) ll[i] = i; while (q--) { scanf("%d%d", &i, &j), i--, j--; ll[j] = min(ll[j], i); } for (p = 1; p <= n; p++) { scanf("%d", &i), i--; pp[i] = p; } lower = -1, upper = n; while (upper - lower > 1) { int k = (lower + upper) / 2; if (solve(k)) upper = k; else lower = k; } printf("%d\n", upper); return 0; }

Compilation message (stderr)

grudanje.c: In function 'main':
grudanje.c:35:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 |  scanf("%s%d", cc, &q), n = strlen(cc);
      |  ^~~~~~~~~~~~~~~~~~~~~
grudanje.c:39:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   39 |   scanf("%d%d", &i, &j), i--, j--;
      |   ^~~~~~~~~~~~~~~~~~~~~
grudanje.c:43:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   43 |   scanf("%d", &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...