Submission #479673

#TimeUsernameProblemLanguageResultExecution timeMemory
479673nicolaalexandraFloppy (RMI20_floppy)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define DIM 100010 #include "floppy.h" using namespace std; int n; int v[DIM]; deque <int> d; string bits; vector <pair<int,int> > events[DIM]; /* void save_to_floppy (string s){ bits = s; cout<<s<<endl; } */ void read_array (int useless, vector<int> &a){ n = a.size(); for (int i=1;i<=n;i++) v[i] = a[i-1]; string bits; for (int i=1;i<=n;i++){ while (!d.empty() && v[i] > v[d.back()]){ d.pop_back(); bits += "1"; } d.push_back(i); bits += "0"; } save_to_floppy(bits); } vector <int> solve_queries (int useless, int n, string &bits, vector<int> &a, vector<int> &b){ int m = a.size(); for (int i=0;i<m;i++){ a[i]++, b[i]++; events[b[i]].push_back(make_pair(a[i],i)); } vector <int> ans(m,0); d.clear(); int poz = 1; for (int i=0;i<bits.length();i++){ if (bits[i] == '0'){ d.push_back(poz); /// rezolv toate query uile cu b ul in poz for (auto it : events[poz]){ int a = it.first; int st = 0, dr = d.size()-1, sol = 0; while (st <= dr){ int mid = (st+dr)>>1; if (d[mid] >= a){ sol = d[mid]; dr = mid-1; } else st = mid+1; } ans[it.second] = sol - 1; } poz++; } else d.pop_back(); } return ans; } /* int main (){ ifstream cin ("date.in"); ofstream cout ("date.out"); int n,m,i,x,y; cin>>n; vector <int> a(n,0); for (i=0;i<n;i++) cin>>a[i]; cin>>m; vector <int> A(m,0); vector <int> B(m,0); for (i=0;i<m;i++) cin>>A[i]>>B[i]; read_array(0,a); vector<int> ans = solve_queries(0,n,bits,A,B); for (auto it : ans) cout<<it<<"\n"; return 0; } */

Compilation message (stderr)

floppy.cpp: In function 'std::vector<int> solve_queries(int, int, std::string&, std::vector<int>&, std::vector<int>&)':
floppy.cpp:50:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |     for (int i=0;i<bits.length();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) {
      |         ~~~~~~~~~~~~~~~~~~~~~^~~~
/usr/bin/ld: /tmp/ccJF2C51.o: in function `run2()':
stub.cpp:(.text+0x698): undefined reference to `solve_queries(int, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::vector<int, std::allocator<int> > const&, std::vector<int, std::allocator<int> > const&)'
/usr/bin/ld: /tmp/ccJF2C51.o: in function `run1()':
stub.cpp:(.text+0xb1d): undefined reference to `read_array(int, std::vector<int, std::allocator<int> > const&)'
collect2: error: ld returned 1 exit status