답안 #1026782

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1026782 2024-07-18T11:02:11 Z boyliguanhan Unscrambling a Messy Bug (IOI16_messy) C++17
100 / 100
2 ms 604 KB
#include <vector>
using namespace std;
#include "messy.h"
vector<int>ans;
int n_;
void write(int l,int r){
    if(l==r)return;
    string str(n_,'1');
    for(int i=l;i<=r;i++)
        str[i]='0';
    for(int i=l;i<=l+r>>1;i++){
        str[i]='1';
        add_element(str);
        str[i]='0';
    }
    write(l,l+r>>1);
    write(l+r+2>>1,r);
}
void read(int l,int r,vector<int>pos){
    if(l==r)return void(ans[pos[0]]=l);
    string str(n_,'1');
    for(auto i:pos)
        str[i]='0';
    vector<int>posl,posr;
    for(auto i:pos){
        str[i]='1';
        if(check_element(str))
            posl.push_back(i);
        else posr.push_back(i);
        str[i]='0';
    }
    read(l,l+r>>1,posl);
    read(l+r+2>>1,r,posr);
}
vector<int> restore_permutation(int n, int w, int r) {
    n_=n;
    ans.resize(n);
    write(0,n-1);
    compile_set();
    vector<int>v2(n);
    for(int i=0;i<n;i++)
        v2[i]=i;
    read(0,n-1,v2);
    return ans;
}

Compilation message

messy.cpp: In function 'void write(int, int)':
messy.cpp:11:21: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   11 |     for(int i=l;i<=l+r>>1;i++){
      |                    ~^~
messy.cpp:16:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   16 |     write(l,l+r>>1);
      |             ~^~
messy.cpp:17:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   17 |     write(l+r+2>>1,r);
      |           ~~~^~
messy.cpp: In function 'void read(int, int, std::vector<int>)':
messy.cpp:32:13: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   32 |     read(l,l+r>>1,posl);
      |            ~^~
messy.cpp:33:13: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   33 |     read(l+r+2>>1,r,posr);
      |          ~~~^~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB n = 8
2 Correct 0 ms 348 KB n = 8
3 Correct 0 ms 348 KB n = 8
4 Correct 0 ms 348 KB n = 8
5 Correct 0 ms 348 KB n = 8
6 Correct 0 ms 348 KB n = 8
7 Correct 0 ms 348 KB n = 8
8 Correct 0 ms 348 KB n = 8
9 Correct 0 ms 348 KB n = 8
10 Correct 0 ms 348 KB n = 8
11 Correct 0 ms 440 KB n = 8
12 Correct 0 ms 348 KB n = 8
13 Correct 1 ms 348 KB n = 8
14 Correct 1 ms 344 KB n = 8
15 Correct 1 ms 348 KB n = 8
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB n = 32
2 Correct 0 ms 436 KB n = 32
3 Correct 0 ms 348 KB n = 32
4 Correct 0 ms 348 KB n = 32
5 Correct 1 ms 348 KB n = 32
6 Correct 0 ms 348 KB n = 32
7 Correct 1 ms 432 KB n = 32
8 Correct 0 ms 348 KB n = 32
9 Correct 0 ms 348 KB n = 32
10 Correct 0 ms 348 KB n = 32
11 Correct 0 ms 348 KB n = 32
12 Correct 0 ms 348 KB n = 32
13 Correct 0 ms 348 KB n = 32
14 Correct 0 ms 348 KB n = 32
15 Correct 0 ms 348 KB n = 32
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB n = 32
2 Correct 1 ms 344 KB n = 32
3 Correct 0 ms 348 KB n = 32
4 Correct 0 ms 348 KB n = 32
5 Correct 0 ms 348 KB n = 32
6 Correct 0 ms 432 KB n = 32
7 Correct 0 ms 348 KB n = 32
8 Correct 0 ms 348 KB n = 32
9 Correct 1 ms 600 KB n = 32
10 Correct 0 ms 348 KB n = 32
11 Correct 0 ms 348 KB n = 32
12 Correct 0 ms 348 KB n = 32
13 Correct 0 ms 432 KB n = 32
14 Correct 1 ms 344 KB n = 32
15 Correct 0 ms 348 KB n = 32
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 604 KB n = 128
2 Correct 1 ms 600 KB n = 128
3 Correct 1 ms 604 KB n = 128
4 Correct 1 ms 604 KB n = 128
5 Correct 1 ms 604 KB n = 128
6 Correct 1 ms 604 KB n = 128
7 Correct 1 ms 604 KB n = 128
8 Correct 1 ms 604 KB n = 128
9 Correct 1 ms 604 KB n = 128
10 Correct 1 ms 604 KB n = 128
11 Correct 1 ms 600 KB n = 128
12 Correct 1 ms 604 KB n = 128
13 Correct 1 ms 604 KB n = 128
14 Correct 1 ms 604 KB n = 128
15 Correct 1 ms 440 KB n = 128
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 604 KB n = 128
2 Correct 1 ms 604 KB n = 128
3 Correct 1 ms 604 KB n = 128
4 Correct 1 ms 604 KB n = 128
5 Correct 1 ms 604 KB n = 128
6 Correct 1 ms 604 KB n = 128
7 Correct 1 ms 604 KB n = 128
8 Correct 2 ms 604 KB n = 128
9 Correct 1 ms 604 KB n = 128
10 Correct 1 ms 604 KB n = 128
11 Correct 1 ms 604 KB n = 128
12 Correct 1 ms 604 KB n = 128
13 Correct 1 ms 604 KB n = 128
14 Correct 1 ms 604 KB n = 128
15 Correct 1 ms 604 KB n = 128