답안 #973014

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
973014 2024-05-01T12:21:45 Z idas Boarding Passes (BOI22_passes) C++11
0 / 100
2000 ms 604 KB
#include <bits/stdc++.h>
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define FOR(i, begin, end) for(int i=(begin); i<(end); i++)
#define sz(x) int((x).size())
#define pb push_back
#define s second
#define f first

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tiii;
typedef long double ld;
typedef long long ll;

const int INF=1e9;

const int N=1e5+10;
int n;
string s;

int main()
{
    FAST_IO;
    cin >> s; n=sz(s);

    set<char> dif;
    FOR(i, 0, n)
    {
        dif.insert(s[i]);
    }

    int m=sz(dif);

    vector<char> ar(dif.begin(), dif.end());
    ll ans=-1;
    do{
        FOR(i, -1, n)
        {
            ll now=0;
            set<char> v;
            FOR(k, 0, m)
            {
                int row=0, add=0;
                FOR(j, 0, n)
                {
                    if(j>i) break;
                    if(v.count(s[j])) add++;
                    else if(s[j]==ar[k]){
                        now+=2*add;

                        row++;
                        now+=(row-1);
                    }
                }

                row=0; add=0;
                for(int j=n-1; j>=0; j--){
                    if(j==i) break;
                    if(v.count(s[j])) add++;
                    else if(s[j]==ar[k]){
                        now+=2*add;

                        row++;
                        now+=(row-1);
                    }
                }

                v.insert(ar[k]);
            }
            if(ans==-1) ans=now;
            else ans=min(ans, now);
//            cout << now << endl;
        }
    }
    while(next_permutation(ar.begin(), ar.end()));

    cout << fixed << setprecision(4) << ans/ld(2);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB found '100800.5000000000', expected '100800.5000000000', error '0.0000000000'
2 Correct 0 ms 348 KB found '0.0000000000', expected '0.0000000000', error '-0.0000000000'
3 Correct 0 ms 348 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 348 KB found '124002.0000000000', expected '124002.0000000000', error '0.0000000000'
6 Execution timed out 2061 ms 604 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB found '1.0000000000', expected '1.0000000000', error '0.0000000000'
2 Correct 0 ms 348 KB found '1225.0000000000', expected '1225.0000000000', error '0.0000000000'
3 Incorrect 1760 ms 424 KB 1st numbers differ - expected: '1023.0000000000', found: '1023.5000000000', error = '0.0004887586'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB found '1.0000000000', expected '1.0000000000', error '0.0000000000'
2 Correct 0 ms 348 KB found '1225.0000000000', expected '1225.0000000000', error '0.0000000000'
3 Incorrect 1760 ms 424 KB 1st numbers differ - expected: '1023.0000000000', found: '1023.5000000000', error = '0.0004887586'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB found '100800.5000000000', expected '100800.5000000000', error '0.0000000000'
2 Correct 0 ms 348 KB found '0.0000000000', expected '0.0000000000', error '-0.0000000000'
3 Correct 0 ms 348 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 348 KB found '124002.0000000000', expected '124002.0000000000', error '0.0000000000'
6 Execution timed out 2061 ms 604 KB Time limit exceeded
7 Halted 0 ms 0 KB -