Submission #1042131

# Submission time Handle Problem Language Result Execution time Memory
1042131 2024-08-02T15:05:22 Z XJP12 Unscrambling a Messy Bug (IOI16_messy) C++14
0 / 100
0 ms 348 KB
#include <bits/stdc++.h>
#include "messy.h"
using namespace std;
typedef vector<int> vi;
/*bool check_element(string x){

}
void compile_set(){

}
void add_element(string x){

}*/
vi restore_permutation(int n, int w, int r){
	add_element("10101010");
	add_element("10010010");
	add_element("01001001");
	compile_set();
	string s;
	vi ans(n);
	int a,b;
	if(!check_element("10101010")){
		s="10101010";
		for(int i=0; i<n; i+=2){
			for(int j=1; j<n; j+=2){
				string t=s;
				swap(t[i],t[j]);
				if(check_element(t)){
					a=i+1;
					b=j+1;
					break;
				}
			}
		}
	}else{
		if(!check_element("10010010")){
			s="10010010";
		}else{
			s="01001001";
		}
		for(int i=0; i<n; i+=3){
			for(int j=1; j<n; j+=3){
				string t=s;
				swap(t[i],t[j]);
				if(check_element(t)){
					a=i+1;
					b=j+1;
					break;
				}
			}
		}
	}
	for(int i=0; i<n; i++){
		ans[i]=i+1;
		if(ans[i]==a){
			ans[i]=b;
			continue;
		}
		if(ans[i]==b){
			ans[i]=a;
			continue;
		}
	}
	return ans;
}

Compilation message

messy.cpp: In function 'vi restore_permutation(int, int, int)':
messy.cpp:59:3: warning: 'b' may be used uninitialized in this function [-Wmaybe-uninitialized]
   59 |   if(ans[i]==b){
      |   ^~
messy.cpp:60:10: warning: 'a' may be used uninitialized in this function [-Wmaybe-uninitialized]
   60 |    ans[i]=a;
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB grader returned WA
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB grader returned WA
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB grader returned WA
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB grader returned WA
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB grader returned WA
2 Halted 0 ms 0 KB -