QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#134046 | #4936. Shopping Changes | Lazy | Compile Error | / | / | C++20 | 3.0kb | 2023-08-02 21:12:36 | 2023-08-02 21:12:37 |
Judging History
你现在查看的是最新测评结果
- [2023-08-10 23:21:45]
- System Update: QOJ starts to keep a history of the judgings of all the submissions.
- [2023-08-02 21:12:37]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-08-02 21:12:36]
- 提交
answer
#include<bits/stdc++.h>
// #define ll int
#define inf 0x3f3f3f3f
#define endl '\n'
#define ull unsigned long long
#define pll pair<ll ,ll>
#define pii pair<int, int>
#define lazy ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
using namespace std;
typedef long long ll;
const ll N = 1e5 + 7;
const ll M = 2e3 + 7;
const double eps = 1e-6;
const ll mod = 998244353;
ll _ = 1, n, m, a[N], tot, num[N];
vector<ll> v[N];
map<ll, ll> mp;
template<class T>
struct BIT {
ll len;
vector<T> c;
BIT(int x){
len=x;
c.resize(len + 1);
}
void init(ll x){
len = x;
c.clear();
c.resize(len + 1);
}// 重构数组
ll lowbit(ll x){
return x & (-x);
}
void modify(ll x, ll y){// 单点加
assert(x <= len);
while (x <= len){
c[x] += y;
x += lowbit(x);
}
}
T query(ll x){// 1-x前缀和
assert(x >= 0);
if (x == 0)return 0;
T res = 0;
while (x){
res += c[x];
x -= lowbit(x);
}
return res;
}
T query(ll l, ll r){return query(r) - query(l - 1);}
};
void doit(ll x){
if (mp.find(x) == mp.end())mp[x] = ++tot;
}
void solve() {
cin >> m >> n;
vector<ll> tempv;
for (int i = 1; i <= m; i++)cin >> a[i], tempv.push_back(a[i]);
for (int i = 1; i <= n; i++){
cin >> num[i];
v[i].push_back(0);
for (int j = 1, x; j <= num[i]; j++){
cin >> x;
tempv.push_back(x);
v[i].push_back(x);
}
}
unique(tempv.begin(), tempv.end());
sort(tempv.begin(), tempv.end());
for (auto i : tempv)doit(i);
for (int i = 1; i <= m; i++)a[i] = mp[a[i]];
for (int i = 1; i <= n; i++){
for (int j = 1; j <= num[i]; j++){
v[i][j] = mp[v[i][j]];
}
}
vector<ll> temp, cntl(tot + 1), cntr(tot + 1);
for (int i = 1; i <= m; i++)temp.push_back(a[i]);
sort(temp.begin(), temp.end());
for (int i = 1; i <= tot; i++){
cntl[i] = max(0ll, lower_bound(temp.begin(), temp.end(), i) - temp.begin());
cntr[i] = temp.end() - upper_bound(temp.begin(), temp.end(), i);
// cerr << i << " " << cntl[i] << " " << cntr[i] << endl;
}
BIT<ll> b(tot);
ll sum = 0;
for (int i = m; i; i--){
sum += b.query(a[i] - 1);
b.modify(a[i], 1);
}
for (int i = 1; i <= n; i++){
ll cnt = sum;
BIT<ll> bn(tot);
for (int j = num[i]; j; j--){
cnt += bn.query(v[i][j] - 1);
bn.modify(v[i][j], 1);
cnt += cntr[v[i][j]];
}
ll ans = cnt;
for (int j = 1; j <= num[i]; j++){
cnt -= cntr[v[i][j]];
cnt += cntl[v[i][j]];
// cerr << j << " " << cnt << endl;
ans = min(ans, cnt);
}
cout << ans << endl;
}
}
int main() {
lazy;
// cin >> _;
while (_--)solve();
}
Details
answer.code: In function ‘void solve()’: answer.code:88:22: error: no matching function for call to ‘max(long long int, __gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >::difference_type)’ 88 | cntl[i] = max(0ll, lower_bound(temp.begin(), temp.end(), i) - temp.begin()); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/11/bits/specfun.h:45, from /usr/include/c++/11/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41, from answer.code:1: /usr/include/c++/11/bits/stl_algobase.h:254:5: note: candidate: ‘template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)’ 254 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/11/bits/stl_algobase.h:254:5: note: template argument deduction/substitution failed: answer.code:88:22: note: deduced conflicting types for parameter ‘const _Tp’ (‘long long int’ and ‘__gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >::difference_type’ {aka ‘long int’}) 88 | cntl[i] = max(0ll, lower_bound(temp.begin(), temp.end(), i) - temp.begin()); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/11/bits/specfun.h:45, from /usr/include/c++/11/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41, from answer.code:1: /usr/include/c++/11/bits/stl_algobase.h:300:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)’ 300 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/11/bits/stl_algobase.h:300:5: note: template argument deduction/substitution failed: answer.code:88:22: note: deduced conflicting types for parameter ‘const _Tp’ (‘long long int’ and ‘__gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >::difference_type’ {aka ‘long int’}) 88 | cntl[i] = max(0ll, lower_bound(temp.begin(), temp.end(), i) - temp.begin()); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/11/string:52, from /usr/include/c++/11/bits/locale_classes.h:40, from /usr/include/c++/11/bits/ios_base.h:41, from /usr/include/c++/11/ios:42, from /usr/include/c++/11/istream:38, from /usr/include/c++/11/sstream:38, from /usr/include/c++/11/complex:45, from /usr/include/c++/11/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54, from answer.code:1: /usr/include/c++/11/bits/stl_algo.h:3461:5: note: candidate: ‘template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)’ 3461 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/11/bits/stl_algo.h:3461:5: note: template argument deduction/substitution failed: answer.code:88:22: note: mismatched types ‘std::initializer_list<_Tp>’ and ‘long long int’ 88 | cntl[i] = max(0ll, lower_bound(temp.begin(), temp.end(), i) - temp.begin()); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/11/string:52, from /usr/include/c++/11/bits/locale_classes.h:40, from /usr/include/c++/11/bits/ios_base.h:41, from /usr/include/c++/11/ios:42, from /usr/include/c++/11/istream:38, from /usr/include/c++/11/sstream:38, from /usr/include/c++/11/complex:45, from /usr/include/c++/11/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54, from answer.code:1: /usr/include/c++/11/bits/stl_algo.h:3467:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)’ 3467 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/11/bits/stl_algo.h:3467:5: note: template argument deduction/substitution failed: answer.code:88:22: note: mismatched types ‘std::initializer_list<_Tp>’ and ‘long long int’ 88 | cntl[i] = max(0ll, lower_bound(temp.begin(), temp.end(), i) - temp.begin()); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~