답안 #411407

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
411407 2021-05-25T08:29:00 Z iulia2100 Monochrome Points (JOI20_monochrome) C++14
25 / 100
2000 ms 324 KB
#include <iostream>

using namespace std;

const int N = 2e5 + 5;

int n;
int alb[N], neg[N], al, ng;
pair <int, int> muchie[N];

//bool idk4(int x, int a, int b)   {
//    if (a < b)
//        swap(a, b);
//    if (idk5() && x < b)
//        return true;
//    return false;
//}

int intersectie(int i,int j){
    int a=muchie[i].first;
    int b=muchie[i].second;
    int c=muchie[j].first;
    int d=muchie[j].second;
    if(a<b)
        swap(a,b);
    if((a>c and c>b) and (a>d and d>b))
        return false;
    if((a<d or d<b) and (a<c or c<b))
        return false;
    return 1;
//    if (idk4(a1, a2, b2) == idk4(b1, a2, b2))
//        return 0;
//    return 1;
}
int idk2(int a){
    if(a<=n)
        return a;
    a-=n;
    return a;
}
int idk(int x)  {
    for(int i=1;i<=n;i++){
        muchie[i]=make_pair(alb[i],neg[idk2(i+x-1)]);
    }
    int cnt = 0;
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            cnt+=intersectie(i,j);
        }
    }
    return cnt;
}

int main()  {
    cin >> n;
    char c;
    int a, ans = 0;
    for (int i = 1; i <= n + n; ++i)    {
        cin >> c;
        a = (c == 'B');
        if(a==0){
            alb[++al]=i;
        } else    {
            neg[++ng] = i;
        }
    }
    for (int i = 1; i <= n; ++i)    {
        ans = max(ans, idk(i));
    }
    cout << ans;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 292 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 296 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 292 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 296 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 27 ms 312 KB Output is correct
15 Correct 28 ms 300 KB Output is correct
16 Correct 27 ms 300 KB Output is correct
17 Correct 26 ms 308 KB Output is correct
18 Correct 18 ms 316 KB Output is correct
19 Correct 22 ms 204 KB Output is correct
20 Correct 21 ms 320 KB Output is correct
21 Correct 24 ms 296 KB Output is correct
22 Correct 21 ms 292 KB Output is correct
23 Correct 8 ms 300 KB Output is correct
24 Correct 18 ms 204 KB Output is correct
25 Correct 19 ms 316 KB Output is correct
26 Correct 21 ms 204 KB Output is correct
27 Correct 28 ms 316 KB Output is correct
28 Correct 25 ms 204 KB Output is correct
29 Correct 19 ms 300 KB Output is correct
30 Correct 20 ms 316 KB Output is correct
31 Correct 21 ms 316 KB Output is correct
32 Correct 25 ms 204 KB Output is correct
33 Correct 27 ms 324 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 292 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 296 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 27 ms 312 KB Output is correct
15 Correct 28 ms 300 KB Output is correct
16 Correct 27 ms 300 KB Output is correct
17 Correct 26 ms 308 KB Output is correct
18 Correct 18 ms 316 KB Output is correct
19 Correct 22 ms 204 KB Output is correct
20 Correct 21 ms 320 KB Output is correct
21 Correct 24 ms 296 KB Output is correct
22 Correct 21 ms 292 KB Output is correct
23 Correct 8 ms 300 KB Output is correct
24 Correct 18 ms 204 KB Output is correct
25 Correct 19 ms 316 KB Output is correct
26 Correct 21 ms 204 KB Output is correct
27 Correct 28 ms 316 KB Output is correct
28 Correct 25 ms 204 KB Output is correct
29 Correct 19 ms 300 KB Output is correct
30 Correct 20 ms 316 KB Output is correct
31 Correct 21 ms 316 KB Output is correct
32 Correct 25 ms 204 KB Output is correct
33 Correct 27 ms 324 KB Output is correct
34 Execution timed out 2068 ms 300 KB Time limit exceeded
35 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 292 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 296 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 27 ms 312 KB Output is correct
15 Correct 28 ms 300 KB Output is correct
16 Correct 27 ms 300 KB Output is correct
17 Correct 26 ms 308 KB Output is correct
18 Correct 18 ms 316 KB Output is correct
19 Correct 22 ms 204 KB Output is correct
20 Correct 21 ms 320 KB Output is correct
21 Correct 24 ms 296 KB Output is correct
22 Correct 21 ms 292 KB Output is correct
23 Correct 8 ms 300 KB Output is correct
24 Correct 18 ms 204 KB Output is correct
25 Correct 19 ms 316 KB Output is correct
26 Correct 21 ms 204 KB Output is correct
27 Correct 28 ms 316 KB Output is correct
28 Correct 25 ms 204 KB Output is correct
29 Correct 19 ms 300 KB Output is correct
30 Correct 20 ms 316 KB Output is correct
31 Correct 21 ms 316 KB Output is correct
32 Correct 25 ms 204 KB Output is correct
33 Correct 27 ms 324 KB Output is correct
34 Execution timed out 2068 ms 300 KB Time limit exceeded
35 Halted 0 ms 0 KB -