답안 #824617

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
824617 2023-08-14T08:18:31 Z LucaIlie Minerals (JOI19_minerals) C++17
40 / 100
15 ms 2504 KB
#include "minerals.h"
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 43000;
const int UNDEF = -1;
int pairr[2 * MAX_N + 1];

void solve( vector <int> &v ) {
    int n = v.size() / 2, ln = n / 2;
    vector<int> left, right;

    if ( n == 1 ) {
        pairr[v[0]] = v[1];
        pairr[v[1]] = v[0];
        return;
    }

    for ( int i: v ) {
        if ( left.size() == ln * 2 || Query( i ) > ln ) {
            right.push_back( i );
            if ( left.size() < ln * 2 )
                Query( i );
        } else
            left.push_back( i );
    }
    for ( int i: left )
        Query( i );

    solve( left );
    solve( right );
}

void Solve( int n ) {
    vector<int> v;
    for ( int i = 1; i <= 2 * n; i++ ) {
        pairr[i] = UNDEF;
        v.push_back( i );
    }

    solve( v );
    for ( int i = 1; i <= 2 * n; i++ ) {
        if ( pairr[i] < i )
            Answer( i, pairr[i] );
    }
}

Compilation message

minerals.cpp: In function 'void solve(std::vector<int>&)':
minerals.cpp:21:26: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   21 |         if ( left.size() == ln * 2 || Query( i ) > ln ) {
      |              ~~~~~~~~~~~~^~~~~~~~~
minerals.cpp:23:30: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   23 |             if ( left.size() < ln * 2 )
      |                  ~~~~~~~~~~~~^~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 2 ms 464 KB Output is correct
4 Correct 5 ms 720 KB Output is correct
5 Correct 9 ms 1184 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 2 ms 464 KB Output is correct
8 Correct 5 ms 720 KB Output is correct
9 Correct 9 ms 1184 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 6 ms 936 KB Output is correct
12 Correct 9 ms 1088 KB Output is correct
13 Correct 9 ms 1240 KB Output is correct
14 Correct 10 ms 1192 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 2 ms 464 KB Output is correct
8 Correct 5 ms 720 KB Output is correct
9 Correct 9 ms 1184 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 6 ms 936 KB Output is correct
12 Correct 9 ms 1088 KB Output is correct
13 Correct 9 ms 1240 KB Output is correct
14 Correct 10 ms 1192 KB Output is correct
15 Incorrect 15 ms 2504 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 2 ms 464 KB Output is correct
8 Correct 5 ms 720 KB Output is correct
9 Correct 9 ms 1184 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 6 ms 936 KB Output is correct
12 Correct 9 ms 1088 KB Output is correct
13 Correct 9 ms 1240 KB Output is correct
14 Correct 10 ms 1192 KB Output is correct
15 Incorrect 15 ms 2504 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 2 ms 464 KB Output is correct
8 Correct 5 ms 720 KB Output is correct
9 Correct 9 ms 1184 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 6 ms 936 KB Output is correct
12 Correct 9 ms 1088 KB Output is correct
13 Correct 9 ms 1240 KB Output is correct
14 Correct 10 ms 1192 KB Output is correct
15 Incorrect 15 ms 2504 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 2 ms 464 KB Output is correct
8 Correct 5 ms 720 KB Output is correct
9 Correct 9 ms 1184 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 6 ms 936 KB Output is correct
12 Correct 9 ms 1088 KB Output is correct
13 Correct 9 ms 1240 KB Output is correct
14 Correct 10 ms 1192 KB Output is correct
15 Incorrect 15 ms 2504 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 2 ms 464 KB Output is correct
8 Correct 5 ms 720 KB Output is correct
9 Correct 9 ms 1184 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 6 ms 936 KB Output is correct
12 Correct 9 ms 1088 KB Output is correct
13 Correct 9 ms 1240 KB Output is correct
14 Correct 10 ms 1192 KB Output is correct
15 Incorrect 15 ms 2504 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 2 ms 464 KB Output is correct
8 Correct 5 ms 720 KB Output is correct
9 Correct 9 ms 1184 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 6 ms 936 KB Output is correct
12 Correct 9 ms 1088 KB Output is correct
13 Correct 9 ms 1240 KB Output is correct
14 Correct 10 ms 1192 KB Output is correct
15 Incorrect 15 ms 2504 KB Wrong Answer [2]
16 Halted 0 ms 0 KB -