Submission #646793

#TimeUsernameProblemLanguageResultExecution timeMemory
646793TwoFourFiveFloppy (RMI20_floppy)C++14
18.45 / 100
192 ms5124 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...