답안 #849019

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
849019 2023-09-13T22:06:48 Z oscar1f Monochrome Points (JOI20_monochrome) C++17
4 / 100
2000 ms 456 KB
#include<bits/stdc++.h>
using namespace std;

#define int long long

int nbVal;
vector<int> initType;
string valDeb;

int verif(int bla1,int noir1,int bla2,int noir2) {
    if (bla1>bla2) {
        return verif(bla2,noir2,bla1,noir1);
    }
    if (bla1>noir1) {
        return verif(noir1,bla1,noir2,bla2);
    }
    if (bla2>bla1 and bla2<noir1) {
        if (noir2>noir1 or noir2<bla1) {
            return 1;
        }
        else {
            return 0;
        }
    }
    else {
        if (noir2>bla1 and noir2<noir1) {
            return 1;
        }
        else {
            return 0;
        }
    }
}

int compt(vector<int> listeBla,vector<int> listeNoir) {
    int nbInter=0;
    for (int i=0;i<nbVal;i++) {
        for (int j=i+1;j<nbVal;j++) {
            nbInter+=verif(listeBla[i],listeNoir[i],listeBla[j],listeNoir[j]);
        }
    }
    return nbInter;
}

int calc(vector<int> typeSom) {
    int rep=0;
    vector<int> listeBla,listeNoir;
    for (int i=0;i<2*nbVal;i++) {
        if (typeSom[i]==0) {
            listeBla.push_back(i);
        }
        else {
            listeNoir.push_back(i);
        }
    }
    while (next_permutation(listeNoir.begin(),listeNoir.end())) {
        rep=max(rep,compt(listeBla,listeNoir));
    }
    rep=max(rep,compt(listeBla,listeNoir));
    return rep;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>nbVal;
    cin>>valDeb;
    for (int i=0;i<2*nbVal;i++) {
        if (valDeb[i]=='W') {
            initType.push_back(0);
        }
        else {
            initType.push_back(1);
        }
    }
    cout<<calc(initType)<<endl;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 6 ms 456 KB Output is correct
10 Correct 6 ms 452 KB Output is correct
11 Correct 7 ms 348 KB Output is correct
12 Correct 4 ms 348 KB Output is correct
13 Correct 6 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 6 ms 456 KB Output is correct
10 Correct 6 ms 452 KB Output is correct
11 Correct 7 ms 348 KB Output is correct
12 Correct 4 ms 348 KB Output is correct
13 Correct 6 ms 348 KB Output is correct
14 Execution timed out 2055 ms 348 KB Time limit exceeded
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 6 ms 456 KB Output is correct
10 Correct 6 ms 452 KB Output is correct
11 Correct 7 ms 348 KB Output is correct
12 Correct 4 ms 348 KB Output is correct
13 Correct 6 ms 348 KB Output is correct
14 Execution timed out 2055 ms 348 KB Time limit exceeded
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 6 ms 456 KB Output is correct
10 Correct 6 ms 452 KB Output is correct
11 Correct 7 ms 348 KB Output is correct
12 Correct 4 ms 348 KB Output is correct
13 Correct 6 ms 348 KB Output is correct
14 Execution timed out 2055 ms 348 KB Time limit exceeded
15 Halted 0 ms 0 KB -