답안 #849021

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
849021 2023-09-13T22:11:18 Z oscar1f Monochrome Points (JOI20_monochrome) C++17
25 / 100
2000 ms 600 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);
        }
    }
    vector<int> ordreNoir;
    for (int i=0;i<nbVal;i++) {
        ordreNoir.clear();
        for (int j=0;j<nbVal;j++) {
            ordreNoir.push_back(listeNoir[(i+j)%nbVal]);
        }
        rep=max(rep,compt(listeBla,ordreNoir));
    }
    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 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 32 ms 344 KB Output is correct
15 Correct 34 ms 492 KB Output is correct
16 Correct 30 ms 344 KB Output is correct
17 Correct 34 ms 344 KB Output is correct
18 Correct 23 ms 348 KB Output is correct
19 Correct 26 ms 344 KB Output is correct
20 Correct 25 ms 344 KB Output is correct
21 Correct 21 ms 344 KB Output is correct
22 Correct 21 ms 344 KB Output is correct
23 Correct 9 ms 344 KB Output is correct
24 Correct 24 ms 344 KB Output is correct
25 Correct 21 ms 344 KB Output is correct
26 Correct 21 ms 464 KB Output is correct
27 Correct 22 ms 344 KB Output is correct
28 Correct 38 ms 464 KB Output is correct
29 Correct 20 ms 344 KB Output is correct
30 Correct 24 ms 344 KB Output is correct
31 Correct 39 ms 468 KB Output is correct
32 Correct 27 ms 344 KB Output is correct
33 Correct 31 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 32 ms 344 KB Output is correct
15 Correct 34 ms 492 KB Output is correct
16 Correct 30 ms 344 KB Output is correct
17 Correct 34 ms 344 KB Output is correct
18 Correct 23 ms 348 KB Output is correct
19 Correct 26 ms 344 KB Output is correct
20 Correct 25 ms 344 KB Output is correct
21 Correct 21 ms 344 KB Output is correct
22 Correct 21 ms 344 KB Output is correct
23 Correct 9 ms 344 KB Output is correct
24 Correct 24 ms 344 KB Output is correct
25 Correct 21 ms 344 KB Output is correct
26 Correct 21 ms 464 KB Output is correct
27 Correct 22 ms 344 KB Output is correct
28 Correct 38 ms 464 KB Output is correct
29 Correct 20 ms 344 KB Output is correct
30 Correct 24 ms 344 KB Output is correct
31 Correct 39 ms 468 KB Output is correct
32 Correct 27 ms 344 KB Output is correct
33 Correct 31 ms 344 KB Output is correct
34 Execution timed out 2037 ms 600 KB Time limit exceeded
35 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 32 ms 344 KB Output is correct
15 Correct 34 ms 492 KB Output is correct
16 Correct 30 ms 344 KB Output is correct
17 Correct 34 ms 344 KB Output is correct
18 Correct 23 ms 348 KB Output is correct
19 Correct 26 ms 344 KB Output is correct
20 Correct 25 ms 344 KB Output is correct
21 Correct 21 ms 344 KB Output is correct
22 Correct 21 ms 344 KB Output is correct
23 Correct 9 ms 344 KB Output is correct
24 Correct 24 ms 344 KB Output is correct
25 Correct 21 ms 344 KB Output is correct
26 Correct 21 ms 464 KB Output is correct
27 Correct 22 ms 344 KB Output is correct
28 Correct 38 ms 464 KB Output is correct
29 Correct 20 ms 344 KB Output is correct
30 Correct 24 ms 344 KB Output is correct
31 Correct 39 ms 468 KB Output is correct
32 Correct 27 ms 344 KB Output is correct
33 Correct 31 ms 344 KB Output is correct
34 Execution timed out 2037 ms 600 KB Time limit exceeded
35 Halted 0 ms 0 KB -