(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.

제출 #231826

#제출 시각아이디문제언어결과실행 시간메모리
231826CodeTiger927Nivelle (COCI20_nivelle)C++14
110 / 110
120 ms11384 KiB
using namespace std; #include <iostream> #include <cstring> #include <algorithm> #include <vector> #define MAXN 100005 int arr[MAXN]; string str; int N; int nextAppear[MAXN][26]; int main() { cin >> N >> str; for(int i = 0;i < N;i++) { arr[i] = str.at(i) - 'a'; } for(int i = 0;i < 26;i++) { nextAppear[N][i] = N; } for(int i = N - 1;i >= 0;--i) { for(int j = 0;j < 26;j++) { nextAppear[i][j] = nextAppear[i + 1][j]; } nextAppear[i][arr[i]] = i; } int ansL; int ansR; double ans = MAXN; for(int i = 0;i < N;i++) { vector<int> v; int active = 0; for(int j = 0;j < 26;j++) { if(nextAppear[i][j] != N) v.push_back(nextAppear[i][j]); if(nextAppear[i][j] != N) active++; } sort(v.begin(),v.end()); double cur = 1.0 * active / (N - i); if(cur < ans) { ansL = i; ansR = N - 1; ans = cur; } for(int j = 1;j < v.size();j++) { double next = 1.0 * j / (v[j] - i); if(next < ans) { ansL = i; ansR = v[j] - 1; ans = next; } } } cout << (ansL + 1) << " " << (ansR + 1) << endl; }

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

nivelle.cpp: In function 'int main()':
nivelle.cpp:46:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j = 1;j < v.size();j++) {
                 ~~^~~~~~~~~~
nivelle.cpp:55:40: warning: 'ansR' may be used uninitialized in this function [-Wmaybe-uninitialized]
  cout << (ansL + 1) << " " << (ansR + 1) << endl;
                                        ^
nivelle.cpp:55:24: warning: 'ansL' may be used uninitialized in this function [-Wmaybe-uninitialized]
  cout << (ansL + 1) << " " << (ansR + 1) << endl;
                        ^~~
#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...