Submission #850525

# Submission time Handle Problem Language Result Execution time Memory
850525 2023-09-16T19:32:01 Z oscar1f Monochrome Points (JOI20_monochrome) C++17
35 / 100
2000 ms 16852 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,temp,mini,maxi;
    for (int i=0;i<nbVal;i++) {
        mini=min(listeBla[i],listeNoir[i]);
        maxi=max(listeBla[i],listeNoir[i]);
        temp=min(maxi-mini-1,2*nbVal-maxi-1+mini);
        //cout<<listeBla[i]<<" "<<listeNoir[i]<<" "<<temp<<" ";
        nbInter+=temp;
    }
    return nbInter/2;
    /*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]);
        }
        int temp=compt(listeBla,ordreNoir);
        //cout<<" = "<<temp<<endl;
        rep=max(rep,temp);
    }
    //cout<<endl;
    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;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 544 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 544 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 1012 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 344 KB Output is correct
27 Correct 2 ms 344 KB Output is correct
28 Correct 1 ms 344 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 344 KB Output is correct
31 Correct 1 ms 344 KB Output is correct
32 Correct 1 ms 544 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 544 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 1012 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 344 KB Output is correct
27 Correct 2 ms 344 KB Output is correct
28 Correct 1 ms 344 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 344 KB Output is correct
31 Correct 1 ms 344 KB Output is correct
32 Correct 1 ms 544 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 24 ms 600 KB Output is correct
35 Correct 24 ms 856 KB Output is correct
36 Correct 23 ms 600 KB Output is correct
37 Correct 22 ms 600 KB Output is correct
38 Correct 21 ms 600 KB Output is correct
39 Correct 22 ms 600 KB Output is correct
40 Correct 19 ms 600 KB Output is correct
41 Correct 18 ms 616 KB Output is correct
42 Correct 25 ms 616 KB Output is correct
43 Correct 23 ms 600 KB Output is correct
44 Correct 21 ms 604 KB Output is correct
45 Correct 21 ms 600 KB Output is correct
46 Correct 24 ms 600 KB Output is correct
47 Correct 23 ms 600 KB Output is correct
48 Correct 24 ms 600 KB Output is correct
49 Correct 20 ms 600 KB Output is correct
50 Correct 25 ms 604 KB Output is correct
51 Correct 23 ms 600 KB Output is correct
52 Correct 24 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 544 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 1012 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 344 KB Output is correct
27 Correct 2 ms 344 KB Output is correct
28 Correct 1 ms 344 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 344 KB Output is correct
31 Correct 1 ms 344 KB Output is correct
32 Correct 1 ms 544 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 24 ms 600 KB Output is correct
35 Correct 24 ms 856 KB Output is correct
36 Correct 23 ms 600 KB Output is correct
37 Correct 22 ms 600 KB Output is correct
38 Correct 21 ms 600 KB Output is correct
39 Correct 22 ms 600 KB Output is correct
40 Correct 19 ms 600 KB Output is correct
41 Correct 18 ms 616 KB Output is correct
42 Correct 25 ms 616 KB Output is correct
43 Correct 23 ms 600 KB Output is correct
44 Correct 21 ms 604 KB Output is correct
45 Correct 21 ms 600 KB Output is correct
46 Correct 24 ms 600 KB Output is correct
47 Correct 23 ms 600 KB Output is correct
48 Correct 24 ms 600 KB Output is correct
49 Correct 20 ms 600 KB Output is correct
50 Correct 25 ms 604 KB Output is correct
51 Correct 23 ms 600 KB Output is correct
52 Correct 24 ms 600 KB Output is correct
53 Execution timed out 2028 ms 16852 KB Time limit exceeded
54 Halted 0 ms 0 KB -