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

제출 #199595

#제출 시각아이디문제언어결과실행 시간메모리
199595quocnguyen1012Nivelle (COCI20_nivelle)C++14
110 / 110
45 ms636 KiB
#include <bits/stdc++.h> #define fi first #define se second #define mp make_pair #define pb push_back using namespace std; typedef long long ll; const int maxn = 1e5 + 5; int N; string str; int cnt[26]; signed main(void) { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if (fopen("A.INP", "r")){ freopen("A.INP", "r", stdin); freopen("A.OUT", "w", stdout); } cin >> N >> str; str = " " + str; int L = 0, R = 0, mxap = 0; for (int type = 1; type <= 26; ++type){ int r = 1, ap = 0; for (int i = 1; i <= N; ++i){ while (r <= N){ if (!cnt[str[r] - 'a']){ if (ap + 1 > type) break; ++ap; } ++cnt[str[r] - 'a']; ++r; } if (mxap == 0 || (mxap * (r - i) > ap * (R - L + 1))){ ///cerr << L << ' ' << R << ' ' << mxap << ' ' << i << ' ' << r - 1 << ' ' << ap << '\n'; mxap = ap; L = i; R = r - 1; } --cnt[str[i] - 'a']; if (cnt[str[i] - 'a'] == 0) --ap; } for (int i = 0; i < 26; ++i) cnt[i] = 0; } cout << L << ' ' << R << '\n'; }

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

nivelle.cpp: In function 'int main()':
nivelle.cpp:21:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     freopen("A.INP", "r", stdin);
     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
nivelle.cpp:22:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     freopen("A.OUT", "w", stdout);
     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
#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...