Submission #768049

#TimeUsernameProblemLanguageResultExecution timeMemory
7680491neUnscrambling a Messy Bug (IOI16_messy)C++14
Compilation error
0 ms0 KiB
#include <vector>
#include "messy.h"
#include <bits/stdc++.h>
using namespace std;
std::vector<int> restore_permutation(int n, int w, int r) {
	 string s;
	 for (int i = 0;i<n;++i){
	 	s+='0';
	 }
	 for (int i  = 0;i<n - 1;++i){
	 	s[i] = '1';
	 	add_element(s);
	 }
    compile_set();
  	 vector<int>pos(n,-1);
  	 string cur;
  	 for (int i = 0;i<n;++i){
  	 	cur+='0';
  	 }                            
  	 for (int i = 0;i<n - 1;++i){
    	for (int j = 0;j<n;++j){
    		if (cur[j] == '1')continue;
    		cur[j] = '1';
    		if (check_element(cur)){
    			pos[i] = j + 1;
    			break;		
    		}
    		cur[j] = '0';	
    	 }
    }
    for (int i = 0;i<n;++i){
    	if (cur[j] == '0'){
    		pos[n - 1] = i + 1;
    	}
    }
    return pos;
}

Compilation message (stderr)

messy.cpp: In function 'std::vector<int> restore_permutation(int, int, int)':
messy.cpp:32:14: error: 'j' was not declared in this scope
   32 |      if (cur[j] == '0'){
      |              ^