제출 #844562

#제출 시각아이디문제언어결과실행 시간메모리
844562vjudge1Nivelle (COCI20_nivelle)C++17
0 / 110
178 ms756 KiB
#include <bits/stdc++.h> #define int long long using namespace std; int32_t main(){ int n;cin>>n; string str;cin>>str; vector<int> ilk(26,-1); vector<int> son(26,-1); for (int i = 0; i < n; i++){ if (ilk[str[i]-'a']==-1) ilk[str[i]-'a']=i; son[str[i]-'a']=i; } vector<int> ls; vector<int> rs; for (int i = 0; i < 26; i++){ if (son[i]==-1) continue; ls.push_back(son[i]+1); ls.push_back(ilk[i]); rs.push_back(ilk[i]-1); rs.push_back(son[i]); } vector<bool> vis(26,true); double hueh = n; int ansl, ansr; for (int ll = 0; ll < ls.size(); ll++){ for (int rr = 0; rr < rs.size(); rr++){ int l = ls[ll]; int r = rs[rr]; if (l>r) continue; fill(vis.begin(), vis.end(), 0); int crr = 0; for (int i = l; i <= r; i++){ if (!vis[str[i]-'a']) crr++; vis[str[i]-'a']=true; } if ((double)crr/(r-l+1)<hueh){ hueh=(double)crr/(r-l+1); ansl = l; ansr = r; } } } cout<<ansl+1<<" "<<ansr+1<<endl; }

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

nivelle.cpp: In function 'int32_t main()':
nivelle.cpp:25:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |  for (int ll = 0; ll < ls.size(); ll++){
      |                   ~~~^~~~~~~~~~~
nivelle.cpp:26:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |   for (int rr = 0; rr < rs.size(); rr++){
      |                    ~~~^~~~~~~~~~~
nivelle.cpp:43:26: warning: 'ansr' may be used uninitialized in this function [-Wmaybe-uninitialized]
   43 |  cout<<ansl+1<<" "<<ansr+1<<endl;
      |                          ^
nivelle.cpp:43:13: warning: 'ansl' may be used uninitialized in this function [-Wmaybe-uninitialized]
   43 |  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...