제출 #209743

#제출 시각아이디문제언어결과실행 시간메모리
209743kapselDifference (POI11_roz)C++14
100 / 100
331 ms8464 KiB
#include <bits/stdc++.h>
 
using namespace std;
 
#define LL long long 
#define ULL unsigned long long 
#define LD long double 

vector<int> wyst[26];
const int INF = 1e9 + 2137;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	string s;
	cin>>s;
	for(int i=0; i<n; i++) {
		wyst[s[i]-97].push_back(i);
	}
	int wynik = 0;
	for(int a=0; a<26; a++) {
		for(int b=0; b<26; b++) {
			vector<int> ciag;
			int i = 0;
			int j = 0;
			int suma = 0;
			int minimum = INF;
			int w = 0;
			int sumap = 0;
			while(i<wyst[a].size() || j<wyst[b].size()) {
				int ob;
				if(i<wyst[a].size() && j<wyst[b].size()) {
					if(wyst[a][i]<wyst[b][j]) {
						ob = 1;
						i++;
					}
					else {
						ob = -1;
						j++;
					}
				}
				else if(i<wyst[a].size()) {
					i++;
					ob = 1;
				}
				else {
					j++;
					ob = -1;
				}
				suma+=ob;
				if(ob==-1) {
					minimum = min(minimum, sumap);
					sumap = suma;
				}
				w = max(w, suma-minimum);
			}
			wynik = max(wynik, w);
		}
	}
	cout<<wynik;
}

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

roz.cpp: In function 'int main()':
roz.cpp:33:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    while(i<wyst[a].size() || j<wyst[b].size()) {
          ~^~~~~~~~~~~~~~~
roz.cpp:33:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    while(i<wyst[a].size() || j<wyst[b].size()) {
                              ~^~~~~~~~~~~~~~~
roz.cpp:35:9: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if(i<wyst[a].size() && j<wyst[b].size()) {
        ~^~~~~~~~~~~~~~~
roz.cpp:35:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if(i<wyst[a].size() && j<wyst[b].size()) {
                            ~^~~~~~~~~~~~~~~
roz.cpp:45:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     else if(i<wyst[a].size()) {
             ~^~~~~~~~~~~~~~~
#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...