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

#TimeUsernameProblemLanguageResultExecution timeMemory
638218ieeGrudanje (COCI19_grudanje)C++17
70 / 70
182 ms6164 KiB
// iee #include <algorithm> #include <iostream> #include <cstring> #include <cstdio> #include <vector> #include <set> #include <map> #define rep(i, a, b) for (auto i = (a); i <= (b); ++i) #define per(i, a, b) for (auto i = (a); i >= (b); --i) #define fi first #define se second using ll = long long; using ull = unsigned long long; using namespace std; void work(int); template <class T> void read(T &x) { x = 0; int f = 1, ch = getchar(); while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); } while (isdigit(ch)) x = x * 10 + (ch - '0'), ch = getchar(); x *= f; } int main() { int TT = 1; // cin >> TT; rep(CAS, 1, TT) work(CAS); return 0; } const int N = 1e5 + 5; int n, q, p[N]; pair<int, int> qry[N]; char s[N], now[N], S[N][26]; bool ok(int mid) { memcpy(now, s, sizeof s); rep(i, 1, mid) now[p[i]] = '*'; rep(i, 1, n) { rep(j, 0, 25) S[i][j] = S[i - 1][j]; if (now[i] != '*') S[i][now[i] - 'a']++; } rep(i, 1, q) { rep(j, 0, 25) { if (S[qry[i].se][j] - S[qry[i].fi - 1][j] > 1) return 0; } } return 1; } void work(int CASE) { scanf("%s", s + 1); n = strlen(s + 1); cin >> q; rep(i, 1, q) { cin >> qry[i].fi >> qry[i].se; } rep(i, 1, n) { cin >> p[i]; } int l = 0, r = n; while (l < r) { int mid = l + r >> 1; if (ok(mid)) r = mid; else l = mid + 1; } cout << l; }

Compilation message (stderr)

grudanje.cpp: In function 'void work(int)':
grudanje.cpp:62:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   62 |     int mid = l + r >> 1;
      |               ~~^~~
grudanje.cpp:51:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   51 |   scanf("%s", s + 1);
      |   ~~~~~^~~~~~~~~~~~~
#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...