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

제출 #1119423

#제출 시각아이디문제언어결과실행 시간메모리
1119423ezzzayNivelle (COCI20_nivelle)C++14
24 / 110
1047 ms596 KiB
#include <iostream> #include <string> #include <unordered_set> #include <vector> #include <limits> using namespace std; pair<int, int> findMinColorfulnessSubsequence(int N, const string& S) { double minColorfulness = numeric_limits<double>::max(); int bestL = 1, bestR = 1; // Try all possible contiguous subsequences for (int L = 0; L < N; L++) { // Track unique colors in current subsequence unordered_set<char> uniqueColors; for (int R = L; R < N; R++) { // Add current toy's color to the set uniqueColors.insert(S[R]); // Calculate colorfulness double colorfulness = 1.0 * uniqueColors.size() / (R - L + 1); // Update best subsequence if current colorfulness is smaller // Use <= to prefer earlier subsequences if colorfulness is same if (colorfulness <= minColorfulness) { minColorfulness = colorfulness; bestL = L + 1; // Convert to 1-based indexing bestR = R + 1; } } } return {bestL, bestR}; } int main() { // Input N and the string of toy colors int N; string S; cin >> N; cin >> S; // Find and output the subsequence with minimal colorfulness auto [L, R] = findMinColorfulnessSubsequence(N, S); cout << L << " " << R << endl; return 0; }

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

nivelle.cpp: In function 'int main()':
nivelle.cpp:47:10: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   47 |     auto [L, R] = findMinColorfulnessSubsequence(N, S);
      |          ^
#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...