답안 #572911

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
572911 2022-06-05T13:26:27 Z MohamedFaresNebili Art Collections (BOI22_art) C++17
0 / 100
1 ms 208 KB
#include <bits/stdc++.h>
#include "art.h"
#include <ext/pb_ds/assoc_container.hpp>

        using namespace std;
        using namespace __gnu_pbds;

        using ll = long long;
        using ii = pair<int, int>;
        using vi = vector<int>;

        #define pb push_back
        #define pp pop_back
        #define ff first
        #define ss second
        #define lb lower_bound
        #define all(x) (x).begin(), (x).end()

        typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update> indexed_set;

        void solve(int N) {
            vector<int> R(N); bool emp[N]{0};
            for(int l = 1; l <= N; l++)
                R[l - 1] = l;
            for(int l = 1; l <= N; l++) {
                int p = 0, e = 0;
                for(int i = 0; i < N; i++) {
                    if(R[i] != l) continue;
                    p = i; break;
                }
                for(int i = 0; i < N; i++) {
                    if(emp[i] == 1) continue;
                    e = i; break;
                }
                swap(R[p], R[e]);
                p = 0; int s = 1e9 + 7; int cr = e;
                for(int i = e; i < N; i++) {
                    if(emp[i]) continue;
                    swap(R[i], R[cr]);
                    int k = publish(R);
                    if(k < s) p = i, s = k;
                    /// swap(R[i], R[cr]);
                    cr = i;
                }
                swap(R[cr], R[p]); emp[p] = 1;
            }
            answer(R);
        }

Compilation message

interface.cpp: In function 'int publish(std::vector<int>)':
interface.cpp:20:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   20 |     if(v.size() != N) {
      |        ~~~~~~~~~^~~~
interface.cpp: In function 'void answer(std::vector<int>)':
interface.cpp:36:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   36 |     if(v.size() != N) {
      |        ~~~~~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Incorrect 1 ms 208 KB Not correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Incorrect 1 ms 208 KB Not correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Incorrect 1 ms 208 KB Not correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Incorrect 1 ms 208 KB Not correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Incorrect 1 ms 208 KB Not correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Incorrect 1 ms 208 KB Not correct
6 Halted 0 ms 0 KB -