Submission #59007

# Submission time Handle Problem Language Result Execution time Memory
59007 2018-07-20T05:01:33 Z tugushka Unscrambling a Messy Bug (IOI16_messy) C++
20 / 100
3 ms 384 KB
#include "messy.h"
#include <bits/stdc++.h>
using namespace std;

vector < int > res;

std::vector<int> restore_permutation(int n, int w, int r) {
	for(int i = 1 ; i < n ; i++){
		string now = "";
		for(int j = 0 ; j < i ; j++) now += '0';
		for(int j = 0 ; j < n-i ; j++) now += '1';
		add_element(now);
	}
    compile_set();
    
    string init;
    for(int i = 0 ; i < n ; i++) init += '1';
    
    for(int i = 1 ; i < n ; i++){
    	string now = init;
    	for(int j = 0 ; j < res.size() ; j++) now[ res[j] ] = '0';
    	
    	for(int j = 0 ; j < n ; j++){
    		if( now[j] == '1' ){
    			string tmp = now;
    			tmp[j] = '0';
    			if( check_element( tmp ) ){
//    				cout << i-1 << ' ' << j << endl;
					res.push_back( j );
					break;
				}
			}
		}
	}
	
	for(int i = 0 ; i < n ; i++){
		bool f = 1;
		for(int j = 0 ; j < res.size() ; j++)
			if( i == res[j] ) f = 0;
		if( f ){
			res.push_back(i);
			break;
		}
	}
	/*
	int last = n*(n-1)/2;
    for(int i = 0 ; i < res.size() ; i++) last -= res[i];
    res.push_back(last);
    */
    return res;
}

Compilation message

messy.cpp: In function 'std::vector<int> restore_permutation(int, int, int)':
messy.cpp:21:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
      for(int j = 0 ; j < res.size() ; j++) now[ res[j] ] = '0';
                      ~~^~~~~~~~~~~~
messy.cpp:38:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j = 0 ; j < res.size() ; j++)
                   ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB n = 8
2 Correct 2 ms 384 KB n = 8
3 Correct 2 ms 256 KB n = 8
4 Correct 2 ms 384 KB n = 8
5 Correct 2 ms 384 KB n = 8
6 Correct 2 ms 384 KB n = 8
7 Correct 2 ms 384 KB n = 8
8 Correct 2 ms 384 KB n = 8
9 Correct 2 ms 384 KB n = 8
10 Correct 2 ms 384 KB n = 8
11 Correct 2 ms 256 KB n = 8
12 Correct 2 ms 384 KB n = 8
13 Correct 2 ms 384 KB n = 8
14 Correct 2 ms 384 KB n = 8
15 Correct 2 ms 384 KB n = 8
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB grader returned WA
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB n = 32
2 Correct 2 ms 256 KB n = 32
3 Incorrect 2 ms 256 KB grader returned WA
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 384 KB grader returned WA
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB grader returned WA
2 Halted 0 ms 0 KB -