QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#306954#8050. Random Permutationinstallb#Compile Error//C++143.4kb2024-01-17 18:15:032024-01-17 18:15:04

Judging History

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

  • [2024-01-17 18:15:04]
  • 评测
  • [2024-01-17 18:15:03]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int N = 300005;
const int B = 105;

#define lson (x << 1)
#define rson ((x << 1) | 1)

struct node{
    pair <int,int> mx[B + 5];
    pair <int,int> mi[B + 5];
    int tag;
}t[N << 2];

node merge(const node &nx,const node &ny){
    node ret;
    int cx = 1,cy = 1;
    for(int i = 1;i <= B;i ++){
        if(nx.mx[cx].first == ny.mx[cy].first){
            ret.mx[i] = make_pair(nx.mx[cx].first,nx.mx[cx].second + ny.mx[cy].second);
            cx ++; cy ++;
        }
        else if(nx.mx[cx].first > ny.mx[cy].first) ret.mx[i] = nx.mx[cx ++];
        else ret.mx[i] = ny.mx[cy ++];
    }
    cx = cy = 1;
    for(int i = 1;i <= B;i ++){
        if(nx.mi[cx].first == ny.mi[cy].first){
            ret.mi[i] = make_pair(nx.mi[cx].first,nx.mi[cx].second + ny.mi[cy].second);
            cx ++; cy ++;
        }
        else if(nx.mi[cx].first < ny.mi[cy].first) ret.mi[i] = nx.mi[cx ++];
        else ret.mi[i] = ny.mi[cy ++];
    }
}

void pushup(int x){
    t[x] = merge(t[lson],t[rson]);
}

void apply(int x,int v){
    for(int i = 1;i <= B;i ++){
        if(t[x].mx[i].first > -INF) t[x].mx[i].first += v;
        if(t[x].mi[i].first < INF) t[x].mi[i].first += v;
    }
}

void pushdown(int x){
    if(t[x].tag){
        apply(lson,tag[x]); t[lson].tag += t[x].tag;
        apply(rson,tag[x]); t[rson].tag += t[x].tag;
        t[x].tag = 0;
    }
}

void build(int x,int l,int r){
    t[x].tag = 0;
    if(l == r){
        for(int i = 1;i <= B;i ++){
            t[x].mx[i] = make_pair(-INF,0);
            t[x].mi[i] = make_pair(INF,0);
        }
        t[x].mx[1] = t[x].mi[1] = make_pair(0,1);
        return;
    }
    int mid = (l + r) >> 1;
    build(lson,l,mid);
    build(rson,mid + 1,r);
    pushup(x);
}

node query(int x,int l,int r,int L,int R){
    if(L <= l && r <= R) return t[x];
    int mid = (l + r) >> 1;
    pushdown(x);
    if(L <= mid && R <= mid) return query(lson,l,mid,L,R);
    if(L > mid && R > mid) return query(rson,mid + 1,r,L,R);
    return merge(query(lson,l,mid,L,R),query(rson,mid + 1,r,L,R));
}

vboid mod

void solve(){

    // testcase input
    // cin >> n >> m;
    // for(int i = 1;i <= n;i ++) G[i].clear();
    // for(int u,v,i = 1;i <= m;i ++){
    //     cin >> u >> v;
    //     G[u].push_back(v); G[v].push_back(u);
    // }
    // cin >> now;
    // for(int i = 1;i <= n;i ++){
    //     for(int j = 1;j <= G[i].size();j ++) cout << G[i][j - 1] << ' ';
    //     cout << '\n';
    // }

    int cur,s; n = 0;
    ans.clear();
    cin >> cur >> s; // in
    siz[cur] = s;
    // cur = now; s = G[now].size();

    dfs(cur,0);

    for(int i = 1;i <= n;i ++){
        for(int j = 1;j <= siz[i];j ++) mrk[i][j] = 0;
        siz[i] = 0;
        mp[i].clear();
    }
    
    sort(ans.begin(),ans.end());
    ans.erase(unique(ans.begin(),ans.end()),ans.end());

    cout << '!';
    for(auto [u,v] : ans) cout << ' ' << u << ' ' << v;
    cout << endl;

    // cout << n << ' ' << ans.size() << ' ' << 2 * (n + ans.size()) << ' ' << interact_num << '\n';
    // assert(2 * (n + ans.size()) <= interact_num);
    // interact_num = 0;

    string str;
    cin >> str;
    if(str == "Correct") return;
    exit(0);
}

int main(){
    ios::sync_with_stdio(false);
    int TC; cin >> TC;
    while(TC --) solve();
    return 0;
}

詳細信息

answer.code: In function ‘node merge(const node&, const node&)’:
answer.code:37:1: warning: no return statement in function returning non-void [-Wreturn-type]
   37 | }
      | ^
answer.code: In function ‘void pushdown(int)’:
answer.code:52:20: error: ‘tag’ was not declared in this scope; did you mean ‘tan’?
   52 |         apply(lson,tag[x]); t[lson].tag += t[x].tag;
      |                    ^~~
      |                    tan
answer.code: At global scope:
answer.code:83:1: error: ‘vboid’ does not name a type; did you mean ‘void’?
   83 | vboid mod
      | ^~~~~
      | void
answer.code: In function ‘int main()’:
answer.code:134:18: error: ‘solve’ was not declared in this scope
  134 |     while(TC --) solve();
      |                  ^~~~~