Submission #974439

# Submission time Handle Problem Language Result Execution time Memory
974439 2024-05-03T10:43:10 Z Circling Boarding Passes (BOI22_passes) C++17
25 / 100
11 ms 600 KB
/*The British Royal Family and a small cadre of English Fabian Socialists, in
conjunction with the Rockefellers and the Rothchilds, are engaged in a
conspiracy to greatly reduce the population of the human race in order to head
off a Malthusian catastrophe, a catastrophe that could easily be avoided by
simply building a massive amount of nuclear power plants and a number of massive
superhighways and bridges to connect all of the world's continents. But doing
that would cut into the conspiracy's profits. So the British Royal Family
invented environmentalism and neoliberalism in order to hide the truth. And in
order to further reduce the population, the British Royal Family is also the
world's foremost drug trafficking conspiracy. And it uses its control of the IMF
to push austerity in order to kill as many people in the global south as
possible.
And also Henry Kissinger is a gay KGB agent. */
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;


int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    string s;
    cin >> s;
    if (s.length() > 100){
        double l = s.length();
        cout << l / 2 * (l / 2 - 1) / 4.0 + (l - l / 2) * (l - l / 2 - 1) / 4.0;
        return 0;
    }
    double placed[7] = {0, 0, 0, 0, 0, 0, 0}, contl[100], contr, curr, ans = 50005000;
    int fact[8];
    char perm[7];
    fact[0] = 1;
    for (int i = 1; i < 8; i++) fact[i] = fact[i - 1] * i;
    for (int i = 0; i < fact[7]; i++){
        curr = 0;
        for (int j = 0; j < 7; j++) perm[j] = j + 'A';
        for (int j = 7; j > 1; j--) swap(perm[7 - j], perm[7 - j + (i / fact[j - 1]) % j]);
        for (int i = 0; i < 7; i++) placed[i] = 0;
        for (int j = 0; j < s.length(); j++){
            contl[j] = placed[s[j] - 'A'] / 2;
            for (int k = 0; perm[k] != s[j]; k++) contl[j] += placed[perm[k] - 'A'];
            placed[s[j] - 'A']++;
        }
        for (int i = 0; i < 7; i++) placed[i] = 0;
        for (int j = s.length() - 1; j >= 0; j--){
            contr = placed[s[j] - 'A'] / 2;
            for (int k = 0; perm[k] != s[j]; k++) contr += placed[perm[k] - 'A'];
            curr += min(contl[j], contr);
            placed[s[j] - 'A']++;
        }
        ans = min(ans, curr);
    }
    cout << ans;
}

Compilation message

passes.cpp: In function 'int main()':
passes.cpp:45:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |         for (int j = 0; j < s.length(); j++){
      |                         ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st numbers differ - expected: '100800.5000000000', found: '100800.0000000000', error = '0.0000049603'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB found '1.0000000000', expected '1.0000000000', error '0.0000000000'
2 Correct 5 ms 348 KB found '1225.0000000000', expected '1225.0000000000', error '0.0000000000'
3 Correct 10 ms 348 KB found '1023.0000000000', expected '1023.0000000000', error '0.0000000000'
4 Correct 4 ms 456 KB found '294.0000000000', expected '294.0000000000', error '0.0000000000'
5 Correct 5 ms 348 KB found '1087.0000000000', expected '1087.0000000000', error '0.0000000000'
6 Correct 1 ms 456 KB found '1.5000000000', expected '1.5000000000', error '0.0000000000'
7 Correct 6 ms 348 KB found '703.0000000000', expected '703.0000000000', error '0.0000000000'
8 Correct 3 ms 348 KB found '55.5000000000', expected '55.5000000000', error '0.0000000000'
9 Correct 3 ms 348 KB found '56.0000000000', expected '56.0000000000', error '0.0000000000'
10 Correct 3 ms 348 KB found '45.0000000000', expected '45.0000000000', error '0.0000000000'
11 Correct 3 ms 348 KB found '66.5000000000', expected '66.5000000000', error '0.0000000000'
12 Correct 4 ms 348 KB found '67.0000000000', expected '67.0000000000', error '0.0000000000'
13 Correct 3 ms 348 KB found '66.0000000000', expected '66.0000000000', error '0.0000000000'
14 Correct 3 ms 600 KB found '47.0000000000', expected '47.0000000000', error '0.0000000000'
15 Correct 4 ms 344 KB found '50.0000000000', expected '50.0000000000', error '0.0000000000'
16 Correct 3 ms 348 KB found '49.0000000000', expected '49.0000000000', error '0.0000000000'
17 Correct 3 ms 348 KB found '57.0000000000', expected '57.0000000000', error '0.0000000000'
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB found '1.0000000000', expected '1.0000000000', error '0.0000000000'
2 Correct 5 ms 348 KB found '1225.0000000000', expected '1225.0000000000', error '0.0000000000'
3 Correct 10 ms 348 KB found '1023.0000000000', expected '1023.0000000000', error '0.0000000000'
4 Correct 4 ms 456 KB found '294.0000000000', expected '294.0000000000', error '0.0000000000'
5 Correct 5 ms 348 KB found '1087.0000000000', expected '1087.0000000000', error '0.0000000000'
6 Correct 1 ms 456 KB found '1.5000000000', expected '1.5000000000', error '0.0000000000'
7 Correct 6 ms 348 KB found '703.0000000000', expected '703.0000000000', error '0.0000000000'
8 Correct 3 ms 348 KB found '55.5000000000', expected '55.5000000000', error '0.0000000000'
9 Correct 3 ms 348 KB found '56.0000000000', expected '56.0000000000', error '0.0000000000'
10 Correct 3 ms 348 KB found '45.0000000000', expected '45.0000000000', error '0.0000000000'
11 Correct 3 ms 348 KB found '66.5000000000', expected '66.5000000000', error '0.0000000000'
12 Correct 4 ms 348 KB found '67.0000000000', expected '67.0000000000', error '0.0000000000'
13 Correct 3 ms 348 KB found '66.0000000000', expected '66.0000000000', error '0.0000000000'
14 Correct 3 ms 600 KB found '47.0000000000', expected '47.0000000000', error '0.0000000000'
15 Correct 4 ms 344 KB found '50.0000000000', expected '50.0000000000', error '0.0000000000'
16 Correct 3 ms 348 KB found '49.0000000000', expected '49.0000000000', error '0.0000000000'
17 Correct 3 ms 348 KB found '57.0000000000', expected '57.0000000000', error '0.0000000000'
18 Correct 1 ms 348 KB found '1.0000000000', expected '1.0000000000', error '0.0000000000'
19 Correct 4 ms 348 KB found '1225.0000000000', expected '1225.0000000000', error '0.0000000000'
20 Correct 11 ms 348 KB found '1023.0000000000', expected '1023.0000000000', error '0.0000000000'
21 Correct 5 ms 344 KB found '294.0000000000', expected '294.0000000000', error '0.0000000000'
22 Correct 5 ms 348 KB found '1087.0000000000', expected '1087.0000000000', error '0.0000000000'
23 Correct 2 ms 344 KB found '1.5000000000', expected '1.5000000000', error '0.0000000000'
24 Correct 6 ms 348 KB found '703.0000000000', expected '703.0000000000', error '0.0000000000'
25 Correct 3 ms 344 KB found '55.5000000000', expected '55.5000000000', error '0.0000000000'
26 Correct 3 ms 348 KB found '56.0000000000', expected '56.0000000000', error '0.0000000000'
27 Correct 3 ms 348 KB found '45.0000000000', expected '45.0000000000', error '0.0000000000'
28 Correct 3 ms 348 KB found '66.5000000000', expected '66.5000000000', error '0.0000000000'
29 Correct 3 ms 348 KB found '67.0000000000', expected '67.0000000000', error '0.0000000000'
30 Correct 3 ms 348 KB found '66.0000000000', expected '66.0000000000', error '0.0000000000'
31 Correct 4 ms 456 KB found '47.0000000000', expected '47.0000000000', error '0.0000000000'
32 Correct 3 ms 348 KB found '50.0000000000', expected '50.0000000000', error '0.0000000000'
33 Correct 3 ms 344 KB found '49.0000000000', expected '49.0000000000', error '0.0000000000'
34 Correct 3 ms 348 KB found '57.0000000000', expected '57.0000000000', error '0.0000000000'
35 Correct 0 ms 344 KB found '12497500.0000000000', expected '12497500.0000000000', error '0.0000000000'
36 Incorrect 0 ms 348 KB 1st numbers differ - expected: '12495000.5000000000', found: '12495000.0000000000', error = '0.0000000400'
37 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st numbers differ - expected: '100800.5000000000', found: '100800.0000000000', error = '0.0000049603'
2 Halted 0 ms 0 KB -