답안 #494473

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
494473 2021-12-15T14:18:09 Z maks007 Floppy (RMI20_floppy) C++14
0 / 100
41 ms 3604 KB
#include <stdlib.h>
#include <string.h>
#include <bits/stdc++.h>
#include "floppy.h"
using namespace std;

string to_bin(int n) {
	string bin = "";
	for(int i = 0; i < 31; i ++) {
		if(n & (1 << i)) bin += '1';
		else bin += '0'; 
	}
	return bin;
}

void read_array(int subtask_id, const vector<int> &v) {
    //vector <bitset <32>> bit(v.size());
    string bits = "";
    for(int i = 0; i < v.size(); i ++) {
    	for(int j = 0; j <= 30; j ++) {
    		if(v[i] & (1 << j)) bits += "1";
    		else bits += "0";
		}
	}
	save_to_floppy(bits);
}


vector<int> solve_queries(int subtask_id, int N,
        const string &bits,
        const vector<int> &a, const vector<int> &b) {
	
  	vector <int> ans;
  	for(int i = 0; i < a.size(); i ++) {
  		function <pair <int, int> (int , int)> mxx=[&](int l, int r) {
  			l *= 31;
			r *= 31;	
			int idx = l / 31;
			pair <int, int> res = {INT_MIN, 0};
			while(l <= r) {
				int pov = 1, sum = 0, cnt = 31;
				while(cnt --) {
					if(bits[i] == '1') sum += pov;
					pov <<= 1;
					l ++;
				}
				res = max(res, {sum, idx});
				idx ++;
			}
			return res;
		};
  		ans.push_back(mxx(a[i], b[i]).second);	
	}
	return ans;
}

Compilation message

floppy.cpp: In function 'void read_array(int, const std::vector<int>&)':
floppy.cpp:19:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |     for(int i = 0; i < v.size(); i ++) {
      |                    ~~^~~~~~~~~~
floppy.cpp: In function 'std::vector<int> solve_queries(int, int, const string&, const std::vector<int>&, const std::vector<int>&)':
floppy.cpp:34:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |    for(int i = 0; i < a.size(); i ++) {
      |                   ~~^~~~~~~~~~
stub.cpp: In function 'void run2()':
stub.cpp:101:30: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  101 |     if (query_answers.size() != M) {
      |         ~~~~~~~~~~~~~~~~~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 788 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 1412 KB L is too large
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 41 ms 3604 KB L is too large
2 Halted 0 ms 0 KB -