제출 #50689

#제출 시각아이디문제언어결과실행 시간메모리
50689Mamnoon_SiamUnscrambling a Messy Bug (IOI16_messy)C++17
49 / 100
3 ms408 KiB
#include <bits/stdc++.h>
using namespace std;
 
void add_element(std::string x);
bool check_element(std::string x);
void compile_set();
 
std::vector<int> restore_permutation(int n, int w, int r)
{
	srand(time(0));
    vector<int> ret=vector<int>(n);
    for(int i=0; i<n; i++) ret[i]=-1;
    string cur=string(n, '0');
    for(int i=n-1; i>0; i--) {
        cur[i]='1';
        add_element(cur);
    }
    compile_set();
    for(int i=0; i<cur.size(); i++) cur[i]='0';
    for(int pos=n-1; pos>0; pos--) {
        vector<int> foo;
        for(int i = 0; i < n; i++) {
        	if(cur[i] == '0') {
        		foo.push_back(i);
        	}
        }
        random_shuffle(foo.begin(), foo.end(), [](int i){return rand()%i;});
        for(int i : foo) {
        	string temp = cur; temp[i] = '1';
        	if(check_element(temp) == 1) {
        		cur = temp;
        		ret[i] = pos;
        		goto siam;
        	}
        }
        siam : ;
    }
    for(int i=0; i<n; i++) {
        if(ret[i]==-1) {
            ret[i]=0;
            break;
        }
    }
    return ret;
}

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

messy.cpp: In function 'std::vector<int> restore_permutation(int, int, int)':
messy.cpp:19:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0; i<cur.size(); i++) cur[i]='0';
                  ~^~~~~~~~~~~
#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...