Submission #852514

# Submission time Handle Problem Language Result Execution time Memory
852514 2023-09-21T21:34:58 Z MinaRagy06 Boarding Passes (BOI22_passes) C++17
5 / 100
1 ms 1116 KB
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    string s;
    cin >> s;
    int n = s.size();
    set<char> chars;
    for (auto i : s) {
        chars.insert(i);
    }
    int mp[255]{}, ctr = 0;
    for (auto i : chars) {
        mp[i] = ctr++;
    }
    int m = chars.size();
    int a[n];
    for (int i = 0; i < n; i++) {
        a[i] = mp[s[i]];
    }
    double ans = 1e18;
    for (int j = 0; j <= n; j++) {
        ans = min(ans, 1.0 * j * (j - 1) / 4.0 + 1.0 * (n - j) * (n - j - 1) / 4.0);
    }
    cout << fixed << setprecision(3) << ans << '\n';
    return 0;
}

Compilation message

passes.cpp: In function 'int main()':
passes.cpp:16:12: warning: array subscript has type 'char' [-Wchar-subscripts]
   16 |         mp[i] = ctr++;
      |            ^
passes.cpp:21:23: warning: array subscript has type 'char' [-Wchar-subscripts]
   21 |         a[i] = mp[s[i]];
      |                       ^
passes.cpp:18:9: warning: unused variable 'm' [-Wunused-variable]
   18 |     int m = chars.size();
      |         ^
passes.cpp:19:9: warning: variable 'a' set but not used [-Wunused-but-set-variable]
   19 |     int a[n];
      |         ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB found '100800.5000000000', expected '100800.5000000000', error '0.0000000000'
2 Correct 1 ms 344 KB found '0.0000000000', expected '0.0000000000', error '-0.0000000000'
3 Correct 0 ms 344 KB found '0.0000000000', expected '0.0000000000', error '-0.0000000000'
4 Correct 0 ms 348 KB found '1.0000000000', expected '1.0000000000', error '0.0000000000'
5 Correct 1 ms 344 KB found '124002.0000000000', expected '124002.0000000000', error '0.0000000000'
6 Correct 1 ms 856 KB found '772893586.0000000000', expected '772893586.0000000000', error '0.0000000000'
7 Correct 1 ms 1112 KB found '1100977812.5000000000', expected '1100977812.5000000000', error '0.0000000000'
8 Correct 1 ms 1116 KB found '1249950000.5000000000', expected '1249950000.5000000000', error '0.0000000000'
9 Correct 1 ms 1112 KB found '1249975000.0000000000', expected '1249975000.0000000000', error '0.0000000000'
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st numbers differ - expected: '1.0000000000', found: '3.0000000000', error = '2.0000000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st numbers differ - expected: '1.0000000000', found: '3.0000000000', error = '2.0000000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB found '100800.5000000000', expected '100800.5000000000', error '0.0000000000'
2 Correct 1 ms 344 KB found '0.0000000000', expected '0.0000000000', error '-0.0000000000'
3 Correct 0 ms 344 KB found '0.0000000000', expected '0.0000000000', error '-0.0000000000'
4 Correct 0 ms 348 KB found '1.0000000000', expected '1.0000000000', error '0.0000000000'
5 Correct 1 ms 344 KB found '124002.0000000000', expected '124002.0000000000', error '0.0000000000'
6 Correct 1 ms 856 KB found '772893586.0000000000', expected '772893586.0000000000', error '0.0000000000'
7 Correct 1 ms 1112 KB found '1100977812.5000000000', expected '1100977812.5000000000', error '0.0000000000'
8 Correct 1 ms 1116 KB found '1249950000.5000000000', expected '1249950000.5000000000', error '0.0000000000'
9 Correct 1 ms 1112 KB found '1249975000.0000000000', expected '1249975000.0000000000', error '0.0000000000'
10 Incorrect 0 ms 344 KB 1st numbers differ - expected: '1.0000000000', found: '3.0000000000', error = '2.0000000000'
11 Halted 0 ms 0 KB -