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

Submission #883607

#TimeUsernameProblemLanguageResultExecution timeMemory
883607mgl_diamondNivelle (COCI20_nivelle)C++17
110 / 110
66 ms552 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using ii = pair<int, int>; #define foru(i, l, r) for(int i=(l); i<=(r); ++i) #define ford(i, l, r) for(int i=(l); i>=(r); --i) #define fore(x, v) for(auto &x : v) #define all(x) (x).begin(), (x).end() #define sz(x) (int)(x).size() #define fi first #define se second #define file "input" template<class T> bool minimize(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } template<class T> bool maximize(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } void setIO() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); if (fopen(file".inp", "r")) { freopen(file".inp", "r", stdin); freopen(file".out", "w", stdout); } } const int N = 1e5+5; int n; string s; int main() { setIO(); vector<int> lst(26); cin >> n; double best = N; int a1, a2; foru(i, 1, n) { char c; cin >> c; c -= 'a'; lst[c] = i; vector<int> range; foru(j, 0, 25) if (lst[j] > 0) range.push_back(lst[j]); sort(all(range)); // cout << "I " << i << "\n"; ford(j, sz(range)-1, 0) { int len = i - (j == 0 ? 0 : range[j-1]); // cout << double(sz(range) - j) / double(len) << "\n"; if (double(sz(range) - j) / double(len) < best) { a1 = i-len+1; a2 = i; best = double(sz(range) - j) / double(len); } } } cout << a1 << " " << a2; }

Compilation message (stderr)

nivelle.cpp: In function 'void setIO()':
nivelle.cpp:22:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |     freopen(file".inp", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
nivelle.cpp:23:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |     freopen(file".out", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
nivelle.cpp: In function 'int main()':
nivelle.cpp:63:24: warning: 'a2' may be used uninitialized in this function [-Wmaybe-uninitialized]
   63 |   cout << a1 << " " << a2;
      |                        ^~
nivelle.cpp:63:17: warning: 'a1' may be used uninitialized in this function [-Wmaybe-uninitialized]
   63 |   cout << a1 << " " << a2;
      |                 ^~~
#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...