제출 #478109

#제출 시각아이디문제언어결과실행 시간메모리
478109mychecksedadNivelle (COCI20_nivelle)C++17
103 / 110
234 ms71480 KiB
/* Author : Mychecksdead */ #include<bits/stdc++.h> using namespace std; typedef long long int ll; typedef long double ld; #define MOD (1000000000+7) #define MOD1 (998244353) #define PI 3.1415926535 #define pb push_back #define setp() cout << setprecision(15) #define all(x) x.begin(), x.end() const int N = 1e6+100, M = 1e5+10, F = 2147483646, K = 20; int n, arr[N]; string s; vector<vector<bool>> dp(N, vector<bool>(26)); int ansx = 0, ansy = 0; double ans = F; void solve(){ cin >> n >> s; for(int i =0 ; i <= n; ++i) arr[i] = 0; for(int i = 1; i <= n; ++i){ int cur = i; int poss = s[i - 1] - 'a'; while(cur > 0 && dp[cur][poss] == 0){ dp[cur][poss] = 1; ++arr[cur]; --cur; } for(int s = 1; s <= 26; ++s){ int l = 1, r = i; int pos = i + 1; while(l <= r){ int mid = (l+r)/2; if(arr[mid] == s){ pos = mid; r = mid - 1; }else l = mid + 1; } if(pos <= i){ if((double) s / double(i - pos + 1) < ans){ ans = (double) s / double(i - pos + 1); ansx = pos; ansy = i; } } } } cout << ansx << ' ' << ansy; } int main(){ cin.tie(0); ios::sync_with_stdio(0); int T = 1, aa; // cin >> T;aa=T; while(T--){ // cout << "Case #" << aa-T << ": "; solve(); } return 0; }

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

nivelle.cpp: In function 'int main()':
nivelle.cpp:58:16: warning: unused variable 'aa' [-Wunused-variable]
   58 |     int T = 1, aa;
      |                ^~
#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...