Submission #502161

# Submission time Handle Problem Language Result Execution time Memory
502161 2022-01-05T11:31:44 Z keta_tsimakuridze Floppy (RMI20_floppy) C++14
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
#include "floppy.h"
#define pii pair<int,int>
#define f first
#define s second
using namespace std;
const int maxn = 1e5 + 5;
pii tree[4 * maxn], t[4 * maxn], count = 0;
vector<int> A;
int n, cur = 0;
string bits, s;
void upd(int u,int ind,int l,int r,int val) {
	if(l > ind || r < ind) return;
	if(l == r) {
		t[u] = {val, l};
		return;
	}
	int mid = (l + r) / 2;
	upd(2 * u, ind, l, mid, val); upd(2 * u + 1, ind, mid + 1, r, val);
	t[u] = min(t[2 * u], t[2 * u + 1]);
}
pii Get(int u,int st,int en,int l,int r) {
	if(l > en || r < st) return {n + 1, 0};
	if(st <= l && r <= en) {
	return t[u]; }
	int mid = (l + r) / 2;
	return min(Get(2 * u, st, en, l, mid), Get(2 * u + 1, st, en, mid + 1, r));
}
void go(int l,int r) {
	if(l > r) return;
	int x = 0;
	for(int i = cur; i < cur + 16; i++) {
		x += (s[i] == '1') * (1 << (i - cur));
	}
	cur += 16;
	upd(1, x, 0, n, cur / 16 - 1);
	go(l, x - 1); go(x + 1, r); 
}
std::vector<int> solve_queries(int subtask_id, int N,
        const std::string &bits,
        const std::vector<int> &a, const std::vector<int> &b) {
        s = bits; n = N - 1;
        cur = 0;
        go(0, n); 
        vector<int> ans(a.size());
     
        for(int i = 0; i < a.size(); i++) { 
        	ans[i] = Get(1, a[i], b[i], 0, n).s;
		} 
		return ans;
}
void build(int u,int l,int r) {
	if(l == r) {
		tree[u] = {A[l], l};
		return;
	}
	int mid = (l + r) / 2;
	build(2 * u, l, mid); build(2 * u + 1, mid + 1, r);
	tree[u] = max(tree[2 * u], tree[2 * u + 1]);
}
pii get(int u, int st,int en,int l,int r) {
	if(l > en || r < st) return {-1, 0};
	if(st <= l && r <= en) return tree[u];
	int mid = (l + r) / 2;
	return max(get(2 * u, st, en, l, mid), get(2 * u + 1, st, en, mid + 1, r));
}
void solve(int l,int r) {
	if(l > r) return; 
	int x = get(1, l, r, 0, n).s;
	count++;
	assert(count <= n + 1);
	for(int i = 0; i < 16; i++) {
		if((1 << i) & x) bits += '1'; 
		else bits += '0';
	}
	solve(l,  x - 1); solve(x + 1, r);
}
void read_array(int subtask_id, const std::vector<int> &v) {
    bits = "";
    n = v.size(); n--;
    A = v;
    count  = 0;
    build(1, 0, n);
    solve(0, n); 
    save_to_floppy(bits);
}

Compilation message

floppy.cpp:8:42: error: conversion from 'int' to non-scalar type 'std::pair<int, int>' requested
    8 | pii tree[4 * maxn], t[4 * maxn], count = 0;
      |                                          ^
floppy.cpp: In function 'std::vector<int> solve_queries(int, int, const string&, const std::vector<int>&, const std::vector<int>&)':
floppy.cpp:47:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |         for(int i = 0; i < a.size(); i++) {
      |                        ~~^~~~~~~~~~
floppy.cpp: In function 'void solve(int, int)':
floppy.cpp:70:2: error: reference to 'count' is ambiguous
   70 |  count++;
      |  ^~~~~
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from floppy.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:4077:5: note: candidates are: 'template<class _IIter, class _Tp> typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::count(_IIter, _IIter, const _Tp&)'
 4077 |     count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
      |     ^~~~~
floppy.cpp:8:34: note:                 'std::pair<int, int> count'
    8 | pii tree[4 * maxn], t[4 * maxn], count = 0;
      |                                  ^~~~~
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from floppy.cpp:1:
floppy.cpp:71:9: error: reference to 'count' is ambiguous
   71 |  assert(count <= n + 1);
      |         ^~~~~
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from floppy.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:4077:5: note: candidates are: 'template<class _IIter, class _Tp> typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::count(_IIter, _IIter, const _Tp&)'
 4077 |     count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
      |     ^~~~~
floppy.cpp:8:34: note:                 'std::pair<int, int> count'
    8 | pii tree[4 * maxn], t[4 * maxn], count = 0;
      |                                  ^~~~~
floppy.cpp: In function 'void read_array(int, const std::vector<int>&)':
floppy.cpp:82:5: error: reference to 'count' is ambiguous
   82 |     count  = 0;
      |     ^~~~~
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from floppy.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:4077:5: note: candidates are: 'template<class _IIter, class _Tp> typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::count(_IIter, _IIter, const _Tp&)'
 4077 |     count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
      |     ^~~~~
floppy.cpp:8:34: note:                 'std::pair<int, int> count'
    8 | pii tree[4 * maxn], t[4 * maxn], count = 0;
      |                                  ^~~~~
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) {
      |         ~~~~~~~~~~~~~~~~~~~~~^~~~