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

#TimeUsernameProblemLanguageResultExecution timeMemory
579827AGEGrudanje (COCI19_grudanje)C++14
70 / 70
114 ms9220 KiB
#include<bits/stdc++.h> #define F first #define S second #define int long long #define pb push_back using namespace std; const int N=1e6,M=2e3+1,mod=1e9+7; pair<int,int>a[N]; multiset<int>st[26]; int ans[N]; main(){ string s; cin>>s; s='.'+s; int q; cin>>q; int n=q,i=0; while(q--){ cin>>a[i].F>>a[i].S; i++; } for(int i=0;i<s.size()-1;i++){ int x; cin>>x; ans[x]=i+1; } sort(a,a+n); int lst=0,Final_ans=0; int l=1,r=1; for(int i=0;i<n;i++){ if(r>a[i].S) continue; while(r<=a[i].S){ st[s[r]-'a'].insert(ans[r]); r++; } while(l<a[i].F){ st[s[l]-'a'].erase(ans[l]); l++; } for(int j=0;j<26;j++){ if(st[j].size()<=1) continue; int x=*st[j].rbegin(); st[j].erase(st[j].find(*st[j].rbegin())); Final_ans=max(*st[j].rbegin(),Final_ans); st[j].insert(x); /*cout<<i<<" "<<j<<": "; for(auto x:st[j]) cout<<x<<" "; cout<<endl;*/ } } cout<<Final_ans<<endl; return 0; }

Compilation message (stderr)

grudanje.cpp:11:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   11 | main(){
      | ^~~~
grudanje.cpp: In function 'int main()':
grudanje.cpp:28:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |     for(int i=0;i<s.size()-1;i++){
      |                 ~^~~~~~~~~~~
grudanje.cpp:38:9: warning: unused variable 'lst' [-Wunused-variable]
   38 |     int lst=0,Final_ans=0;
      |         ^~~
#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...