QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#621471#8783. Cherry Pickingucup-team2526Compile Error//C++205.1kb2024-10-08 14:44:392024-10-08 14:45:03

Judging History

你现在查看的是最新测评结果

  • [2024-10-08 14:45:03]
  • 评测
  • [2024-10-08 14:44:39]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;

#define dbg(x...) \
do { \
    cout << #x << " -> "; \
    err(x); \
} while (0)

void err() {
    cout<<endl<<endl;
}
 
template<class T, class... Ts>
void err(T arg, Ts ... args) {
    cout<<fixed<<setprecision(10)<<arg<< ' ';
    err(args...);
}

const int maxn = 1e5 + 5;
struct BIT {
    #define lowbit(x) (x&(-x))
    int tr[maxn << 2];
    void add(int u,int v) {
        while (u <= maxn) {
            tr[u] += v;
            u += lowbit(u);
        }
    }
    int get(int u) {
        int res = 0;
        while (u) {
            res += tr[u];
            u -= lowbit(u);
        }
        return res;
    }
}bit;

void solve(){
    int n,k;cin >> n >> k;
    vector<int> a(n + 5);
    for (int i = 1;i <= n;i++) cin >> a[i];
    string res;cin >> res;
    int l = -1,r = -1;
    int cnt = 1,ans = 0;
    for (int i = 1;i <= n;i++) {
        if (res[i - 1] == '1') {
            bit.add(a[i],1);
            l = i,r = i;
            if (k == 1) ans = max(ans,a[i]);
            break;
        }
    }
    //dbg(l,r);
    if (l == -1) {
        cout << 0 << '\n';
        return ;
    }
    multiset<int>s0,s1;
    s1.insert(a[l]);
    while (1) {
        int ok = 0;
        for (int i = r + 1;i <= n;i++) {
            if (res[i - 1] == '0') {
                s0.insert(a[i]);
            }
            else {
                cnt++;
                bit.add(a[i],1);
                s1.insert(a[i]);
                if (cnt >= k) {
                    int mi0;
                    if (s0.empty()) mi0 = 0;
                    else mi0 = *(s0.rbegin());
                    int num = bit.get(mi0);
                    if (cnt - num >= k) {
                        ok = 1;
                        auto it = s1.lower_bound(mi0 + 1);
                        int val = *(it);
                        ans = max(ans,val);
                        r = i;
                        break;
                    }
                }
            }
        }
        if (!ok) break;
        bit.add(a[l],-1);
        cnt--;
        s1.erase(s1.find(a[l]));
        for (int i = l + 1;i <= n;i++) {
            if (res[i - 1] == '0') s0.erase(s0.find(a[i]));
            else {
                l = i;
                ok = 0;
                break;
            }
        }
        if (ok) break;
    }
    cout << ans;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int T = 1;
    //cin >> T;
    while(T--) solve();
    return 0;
}#include<bits/stdc++.h>
#define int long long
using namespace std;

#define dbg(x...) \
do { \
    cout << #x << " -> "; \
    err(x); \
} while (0)

void err() {
    cout<<endl<<endl;
}
 
template<class T, class... Ts>
void err(T arg, Ts ... args) {
    cout<<fixed<<setprecision(10)<<arg<< ' ';
    err(args...);
}

const int maxn = 1e5 + 5;
struct BIT {
    #define lowbit(x) (x&(-x))
    int tr[maxn << 2];
    void add(int u,int v) {
        while (u <= maxn) {
            tr[u] += v;
            u += lowbit(u);
        }
    }
    int get(int u) {
        int res = 0;
        while (u) {
            res += tr[u];
            u -= lowbit(u);
        }
        return res;
    }
}bit;

void solve(){
    int n,k;cin >> n >> k;
    vector<int> a(n + 5);
    for (int i = 1;i <= n;i++) cin >> a[i];
    string res;cin >> res;
    int l = -1,r = -1;
    int cnt = 1,ans = 0;
    for (int i = 1;i <= n;i++) {
        if (res[i - 1] == '1') {
            bit.add(a[i],1);
            l = i,r = i;
            if (k == 1) ans = max(ans,a[i]);
            break;
        }
    }
    //dbg(l,r);
    if (l == -1) {
        cout << 0 << '\n';
        return ;
    }
    multiset<int>s0,s1;
    s1.insert(a[l]);
    while (1) {
        int ok = 0;
        for (int i = r + 1;i <= n;i++) {
            if (res[i - 1] == '0') {
                s0.insert(a[i]);
            }
            else {
                cnt++;
                bit.add(a[i],1);
                s1.insert(a[i]);
                if (cnt >= k) {
                    int mi0;
                    if (s0.empty()) mi0 = 0;
                    else mi0 = *(s0.rbegin());
                    int num = bit.get(mi0);
                    if (cnt - num >= k) {
                        ok = 1;
                        auto it = s1.lower_bound(mi0 + 1);
                        int val = *(it);
                        ans = max(ans,val);
                        r = i;
                        break;
                    }
                }
            }
        }
        if (!ok) break;
        bit.add(a[l],-1);
        cnt--;
        s1.erase(s1.find(a[l]));
        for (int i = l + 1;i <= n;i++) {
            if (res[i - 1] == '0') s0.erase(s0.find(a[i]));
            else {
                l = i;
                ok = 0;
                break;
            }
        }
        if (ok) break;
    }
    cout << ans;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int T = 1;
    //cin >> T;
    while(T--) solve();
    return 0;
}

詳細信息

answer.code:113:2: error: stray ‘#’ in program
  113 | }#include<bits/stdc++.h>
      |  ^
answer.code:113:11: error: ‘bits’ was not declared in this scope; did you mean ‘bit’?
  113 | }#include<bits/stdc++.h>
      |           ^~~~
      |           bit
answer.code:113:16: error: ‘stdc’ was not declared in this scope; did you mean ‘std’?
  113 | }#include<bits/stdc++.h>
      |                ^~~~
      |                std
answer.code:113:11: error: ‘bits’ was not declared in this scope; did you mean ‘bit’?
  113 | }#include<bits/stdc++.h>
      |           ^~~~
      |           bit
answer.code:113:16: error: ‘stdc’ was not declared in this scope; did you mean ‘std’?
  113 | }#include<bits/stdc++.h>
      |                ^~~~
      |                std
answer.code:113:11: error: ‘bits’ was not declared in this scope; did you mean ‘bit’?
  113 | }#include<bits/stdc++.h>
      |           ^~~~
      |           bit
answer.code:113:16: error: ‘stdc’ was not declared in this scope; did you mean ‘std’?
  113 | }#include<bits/stdc++.h>
      |                ^~~~
      |                std
answer.code:113:11: error: ‘bits’ was not declared in this scope; did you mean ‘bit’?
  113 | }#include<bits/stdc++.h>
      |           ^~~~
      |           bit
answer.code:113:16: error: ‘stdc’ was not declared in this scope; did you mean ‘std’?
  113 | }#include<bits/stdc++.h>
      |                ^~~~
      |                std
answer.code:113:11: error: ‘bits’ was not declared in this scope; did you mean ‘bit’?
  113 | }#include<bits/stdc++.h>
      |           ^~~~
      |           bit
answer.code:113:16: error: ‘stdc’ was not declared in this scope; did you mean ‘std’?
  113 | }#include<bits/stdc++.h>
      |                ^~~~
      |                std
answer.code:113:11: error: ‘bits’ was not declared in this scope; did you mean ‘bit’?
  113 | }#include<bits/stdc++.h>
      |           ^~~~
      |           bit
answer.code:113:16: error: ‘stdc’ was not declared in this scope; did you mean ‘std’?
  113 | }#include<bits/stdc++.h>
      |                ^~~~
      |                std
answer.code:113:11: error: ‘bits’ was not declared in this scope; did you mean ‘bit’?
  113 | }#include<bits/stdc++.h>
      |           ^~~~
      |           bit
answer.code:113:16: error: ‘stdc’ was not declared in this scope; did you mean ‘std’?
  113 | }#include<bits/stdc++.h>
      |                ^~~~
      |                std
answer.code:113:11: error: ‘bits’ was not declared in this scope; did you mean ‘bit’?
  113 | }#include<bits/stdc++.h>
      |           ^~~~
      |           bit
answer.code:113:16: error: ‘stdc’ was not declared in this scope; did you mean ‘std’?
  113 | }#include<bits/stdc++.h>
      |                ^~~~
      |                std
answer.code:113:11: error: ‘bits’ was not declared in this scope; did you mean ‘bit’?
  113 | }#include<bits/stdc++.h>
      |           ^~~~
      |           bit
answer.code:113:16: error: ‘stdc’ was not declared in this scope; did you mean ‘std’?
  113 | }#include<bits/stdc++.h>
      |                ^~~~
      |                std
answer.code:113:3: error: ‘include’ does not name a type
  113 | }#include<bits/stdc++.h>
      |   ^~~~~~~
answer.code:123:6: error: redefinition of ‘void err()’
  123 | void err() {
      |      ^~~
answer.code:11:6: note: ‘void err()’ previously defined here
   11 | void err() {
      |      ^~~
answer.code:128:6: error: redefinition of ‘template<class T, class ... Ts> void err(T, Ts ...)’
  128 | void err(T arg, Ts ... args) {
      |      ^~~
answer.code:16:6: note: ‘template<class T, class ... Ts> void err(T, Ts ...)’ previously declared here
   16 | void err(T arg, Ts ... args) {
      |      ^~~
answer.code:133:11: error: redefinition of ‘const long long int maxn’
  133 | const int maxn = 1e5 + 5;
      |           ^~~~
answer.code:21:11: note: ‘const long long int maxn’ previously defined here
   21 | const int maxn = 1e5 + 5;
      |           ^~~~
answer.code:134:8: error: redefinition of ‘struct BIT’
  134 | struct BIT {
      |        ^~~
answer.code:22:8: note: previous definition of ‘struct BIT’
   22 | struct BIT {
      |        ^~~
answer.code:151:2: error: conflicting declaration ‘int bit’
  151 | }bit;
      |  ^~~
answer.code:39:2: note: previous declaration as ‘BIT bit’
   39 | }bit;
      |  ^~~
answer.code:153:6: error: redefinition of ‘void solve()’
  153 | void solve(){
      |      ^~~~~
answer.code:41:6: note: ‘void solve()’ previously defined here
   41 | void solve(){
      |      ^~~~~
answer.code:218:8: error: redefinition of ‘int main()’
  218 | signed main(){
      |        ^~~~
answer.code:106:8: note: ‘int main()’ previously defined here
  106 | signed main(){
      |        ^~~~