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

#TimeUsernameProblemLanguageResultExecution timeMemory
339694HazemGrudanje (COCI19_grudanje)C++14
70 / 70
229 ms13832 KiB
/* ID: tmhazem1 LANG: C++14 TASK: pprime */ #include <bits/stdc++.h> using namespace std; #define S second #define F first #define LL long long const int N = 2e5 + 10; LL LINF = 100000000000000000; LL INF = 1000000000; vector<pair<int,int>>vec; int n,q; int freq[N][26],a[N]; string s; bool ok(int mid){ for(int i=1;i<=n;i++){ char c = a[i]<=mid?'*':s[i-1]; for(int j=0;j<26;j++) freq[i][j] = freq[i-1][j]+(c-'a'==j); } bool q = 1; for(auto x:vec) for(int i=0;i<26;i++) q &= freq[x.S][i]-freq[x.F-1][i]<=1; return q; } int main() { //freopen("out.txt","w",stdout); cin>>s; n = s.size(),q; scanf("%d",&q); while(q--){ int l,r; scanf("%d%d",&l,&r); vec.push_back({l,r}); } for(int i=1;i<=n;i++){ int x;cin>>x; a[x] = i; } int l = 0,r = n-1; while(l<r){ int mid = (l+r)/2; if(ok(mid)) r = mid; else l = mid+1; } printf("%d\n",l); }

Compilation message (stderr)

grudanje.cpp: In function 'int main()':
grudanje.cpp:44:20: warning: right operand of comma operator has no effect [-Wunused-value]
   44 |      n = s.size(),q;
      |                    ^
grudanje.cpp:45:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   45 |     scanf("%d",&q);
      |     ~~~~~^~~~~~~~~
grudanje.cpp:49:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   49 |         scanf("%d%d",&l,&r);
      |         ~~~~~^~~~~~~~~~~~~~
#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...