제출 #1213353

#제출 시각아이디문제언어결과실행 시간메모리
1213353badge881Grudanje (COCI19_grudanje)C++20
70 / 70
122 ms12256 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 10; char s[MAXN]; int n, q; int l[MAXN], r[MAXN], p[MAXN], pp[MAXN], pref[26][MAXN]; bool check(int x) { for (int i = 0; i < 26; ++i) pref[i][0] = 0; for (int i = 0; i < n; ++i) { for (int j = 0; j < 26; ++j) pref[j][i + 1] = pref[j][i]; if (pp[i] > x) pref[s[i] - 'a'][i + 1] += 1; } bool ok = true; for (int i = 0; i < q && ok; ++i) for (int j = 0; j < 26 && ok; ++j) ok &= (pref[j][r[i]] - pref[j][l[i] - 1]) <= 1; return ok; } int main(void) { scanf("%s", s); n = strlen(s); scanf("%d", &q); for (int i = 0; i < q; ++i) scanf("%d%d", &l[i], &r[i]); for (int i = 0; i < n; ++i) { scanf("%d", &p[i]); --p[i]; pp[p[i]] = i + 1; } int lo = 0, hi = n; while (lo < hi) { int mid = (lo + hi) / 2; if (check(mid)) hi = mid; else lo = mid + 1; } printf("%d\n", lo); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

grudanje.cpp: In function 'int main()':
grudanje.cpp:31:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |     scanf("%s", s);
      |     ~~~~~^~~~~~~~~
grudanje.cpp:34:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |     scanf("%d", &q);
      |     ~~~~~^~~~~~~~~~
grudanje.cpp:36:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |         scanf("%d%d", &l[i], &r[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~
grudanje.cpp:40:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |         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...