Submission #1062857

#TimeUsernameProblemLanguageResultExecution timeMemory
1062857TimDeeFloppy (RMI20_floppy)C++17
Compilation error
0 ms0 KiB
// Guess who we ran into at the shops? // Walking in circles like she was lost // Didn't you hear? // They called it all off #include "floppy.h" #include <algorithm> #include <bitset> #include <cassert> #include <chrono> #include <cmath> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <string> #include <vector> typedef long long ll; typedef long double ld; using namespace std; struct sgt { vector<pair<int, int> > st; int n; void init(vector<int> v) { n = v.size(); st.resize(v.size() * 2); for (int i = n; i < 2 * n; i++) st[i] = { v[i - n], i - n }; for (int i = n - 1; i > 0; i--) st[i] = max(st[i * 2], st[i * 2 + 1]); } int query(int l, int r) { pair<int, int> p(-1, -1); for (l += n, r += n + 1; l < r; l >>= 1, r >>= 1) { if (l & 1) p = max(p, st[l++]); if (r & 1) p = max(p, st[--r]); } return p.second; } }; sgt s; void make(int l, int r, string& ans) { if (r < l) return; int i = s.query(l, r); if (l < i) ans.push_back('1'); else ans.push_back('0'); if (r > i) ans.push_back('1'); else ans.push_back('0'); make(l, i - 1, ans); make(i + 1, r, ans); } void read_array(int subtask_id, const vector<int> &v) { s.init(v); string ans; if (n<=500) make(0, v.size() - 1, ans); else {for(int i=0; i<v.size()-1; ++i) ans+="10"; ans+="00";} save_to_floppy(ans); } int tim = 0; // :) :wave: int val; vector<int> v2; int dfs(int u, const string &b) { int x = val, siz = 1; val--; if (b[u * 2] == '1') siz += dfs(u + 1, b); v2[tim++] = x; if (b[u * 2 + 1] == '1') siz += dfs(u + siz, b); return siz; } vector<int> solve_queries(int subtask_id, int n, const string &bits, const vector<int> &a, const vector<int> &b) { val = n - 1; v2.resize(n, -1); dfs(0, bits); s.init(v2); vector<int> ans; for (int i = 0; i < a.size(); i++) ans.push_back(s.query(a[i], b[i])); return ans; }

Compilation message (stderr)

floppy.cpp: In function 'void read_array(int, const std::vector<int>&)':
floppy.cpp:66:11: error: 'n' was not declared in this scope
   66 |       if (n<=500)
      |           ^
floppy.cpp:68:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   68 |       else {for(int i=0; i<v.size()-1; ++i) ans+="10"; ans+="00";}
      |                          ~^~~~~~~~~~~
floppy.cpp: In function 'std::vector<int> solve_queries(int, int, const string&, const std::vector<int>&, const std::vector<int>&)':
floppy.cpp:91:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   91 |         for (int i = 0; i < a.size(); i++) ans.push_back(s.query(a[i], b[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) {
      |         ~~~~~~~~~~~~~~~~~~~~~^~~~