Submission #646793

# Submission time Handle Problem Language Result Execution time Memory
646793 2022-09-30T17:01:35 Z TwoFourFive Floppy (RMI20_floppy) C++14
18.4517 / 100
192 ms 5124 KB
#include <stdlib.h>
#include <string.h>

#include "floppy.h"

#include <bits/stdc++.h>
using namespace std;
typedef int ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<pll> vpl;
const ll INF = 100005, LONGBOI = 100000000005, BITSMAX = 16;


string ToStr(ll x){
    string ans="";
    for(int i=BITSMAX-1; i >= 0; i--){
        ans += '0' + ((x>>i)&1);
    }
    return ans;
}

ll FromStr(string s){
    ll x = 0;
    for(int i=0; i < BITSMAX; i++){
        x <<= 1;
        x += s[i]-'0';
    }
    return x;
}

void read_array(int subtask_id, const vector<int> &v) {
    vl vec;
    map<ll, ll> newNums;
    ll n = v.size();
    for(auto x : v) { vec.push_back(x); }
    sort(vec.begin(), vec.end());
    for(auto x : vec){
        if(newNums.count(x) == false){
            newNums[x] = newNums.size();
        }
    }

    string bits = "";
    for(auto x : v) { bits += ToStr(newNums[x]);  /*cout << bits << endl;*/ }
    //cout << bits << endl;
    save_to_floppy(bits);
}

vector<int> solve_queries(int subtask_id, int N, const string &bits, const vector<int> &a, const vector<int> &b) {
    vl h;
    ll n = bits.length();
    //cout << n << endl;
    for(int i=0; i < n; i+=BITSMAX) { h.push_back(FromStr(bits.substr(i, BITSMAX))); }
    //for(int i=0; i <= maxpos; i++) { cout << "i = " << i << " t[i] = " << t[i].first << " second = " << t[i].second << endl; }

    vl ans;
    ll m  = a.size();
    for(int i=0; i < m; i++){
        ans.push_back(max_element(h.begin()+a[i], h.begin()+b[i]+1) - h.begin());
        //cout << GetMax(0, 1, N, a[i]+1, b[i]+1, t) << endl;
        //ans.push_back(GetMax(0, 1, N, a[i]+1, b[i]+1, t).second);
    }
    //for(auto x : ans) cout << x << " ";
    //cout << endl;

    //vl ans = {0, 0, 0, 0, 1, 2, 2, 2, 2, 3};
    return ans;
}

Compilation message

floppy.cpp:12:34: warning: overflow in conversion from 'long int' to 'll' {aka 'int'} changes value from '100000000005' to '1215752197' [-Woverflow]
   12 | const ll INF = 100005, LONGBOI = 100000000005, BITSMAX = 16;
      |                                  ^~~~~~~~~~~~
floppy.cpp: In function 'void read_array(int, const std::vector<int>&)':
floppy.cpp:35:8: warning: unused variable 'n' [-Wunused-variable]
   35 |     ll n = v.size();
      |        ^
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) {
      |         ~~~~~~~~~~~~~~~~~~~~~^~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 648 KB Output is correct
2 Correct 4 ms 688 KB Output is correct
3 Correct 5 ms 680 KB Output is correct
4 Correct 3 ms 692 KB Output is correct
5 Correct 4 ms 664 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 123 ms 3872 KB Partially correct
2 Partially correct 115 ms 4528 KB Partially correct
3 Partially correct 192 ms 4592 KB Partially correct
4 Partially correct 157 ms 4516 KB Partially correct
5 Partially correct 117 ms 4516 KB Partially correct
# Verdict Execution time Memory Grader output
1 Incorrect 53 ms 5124 KB L is too large
2 Halted 0 ms 0 KB -