제출 #573930

#제출 시각아이디문제언어결과실행 시간메모리
5739302fat2codeUnscrambling a Messy Bug (IOI16_messy)C++17
0 / 100
1 ms340 KiB
#include <bits/stdc++.h>
#include "messy.h"
#define fr first
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define sc second
#define all(s) s.begin(), s.end()
#define rc(s) return cout << s, 0
using namespace std;

vector<int> restore_permutation(int n, int w, int r) {
    string s = "";
    for(int i=1;i<=n;i++) s += '0';
    for(int i=0;i<n;i++){
        s[i] = '1';
        add_element(s);
    }
    compile_set();
    vector<int>p;
    vector<int>pos;
    string curr = "";
    for(int i=1;i<=n;i++) curr += "0";
    for(int i=1;i<=n;i++) pos.push_back(i - 1);
    for(int t=1;t<n;t++){
        curr[pos[0]] = '1';
        if(check_element(curr)){
            p.push_back(pos[0]);
            vector<int>tz;
            for(int i=1;i<(int)pos.size();i++) tz.push_back(pos[i]);
            pos = tz;
            continue;
        }
        for(int i=1;i<pos.size()-1;i++){
            curr[pos[i-1]] = '0';
            curr[pos[i]] = '1';
            if(check_element(curr)){
                p.push_back(pos[i]);
                vector<int>tz;
                for(int j=0;j<i;j++) tz.push_back(pos[j]);
                for(int j=i+1;j<pos.size();j++) tz.push_back(pos[j]);
                pos = tz;
            }
        }
        if(pos.size() == n - t + 1){
            if(pos.size() >= 2){
                curr[pos[pos.size() - 2]] = '0';
            }
            curr[pos.back()] = '1';
            p.push_back(pos.back());
            pos.pop_back();
        }
    }
    p.push_back(pos.back());
    vector<int>lol(n, 0);
    for(int i=0;i<n;i++) lol[p[i]] = i;
    return lol;
}

컴파일 시 표준 에러 (stderr) 메시지

messy.cpp: In function 'std::vector<int> restore_permutation(int, int, int)':
messy.cpp:33:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |         for(int i=1;i<pos.size()-1;i++){
      |                     ~^~~~~~~~~~~~~
messy.cpp:40:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |                 for(int j=i+1;j<pos.size();j++) tz.push_back(pos[j]);
      |                               ~^~~~~~~~~~~
messy.cpp:44:23: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   44 |         if(pos.size() == n - t + 1){
      |            ~~~~~~~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...