QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#380711#7181. Graph Cutsucup-team992#Compile Error//C++203.7kb2024-04-07 09:10:262024-04-07 09:10:27

Judging History

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

  • [2024-04-07 09:10:27]
  • 评测
  • [2024-04-07 09:10:26]
  • 提交

answer

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

#define F first
#define S second
#define ar array
typedef int uci;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

void solve(){
    int n, m;
    cin >> n >> m;

    vector<int> deg(n);
    vector<int> lbig;
    vector<int> big(n, -1);
    vector<int> state(n);
    vector<vector<bitset<100000>>> sides(2);
    vector<unordered_map<int, int>> adj(n);
    vector<ar<int, 2>> edges;
    edges.push_back({});
    vector<vector<int>> sizes(2);
    for(int i{}; i < m; ++i){
        int u, v;
        cin >> u >> v;
        u--, v--;

        edges.push_back({u, v});
        adj[u][v] = i+1;
        adj[v][u] = i+1;
        bitadj[u].set(v);
        bitadj[v].set(u);
        deg[u]++, deg[v]++;
    }

    int sq = sqrt(n);
    for(int i{}; i < n; ++i){
        if(deg[i] >= sq){
            big[i] = sides[0].size();
            lbig.push_back(i);
            sides[0].push_back({});
            sizes[0].push_back(0);
            for(auto t : adj[i]){
                sides[0].back().set(t.F);
                sizes[0].back()++;
            }
            sizes[1].push_back(0);
            sides[1].push_back({});
        }
    }

    int q;
    cin >> q;

    vector<unordered_map<int, int>> bigadj(n);
    for(int i : lbig){
        vector<int> te;
        for(auto &t : adj[i]){
            bigadj[t.F][i] = t.S;
            if(big[t.F] == -1)
                bigadj[i][t.F] = t.S;
            te.push_back(t.F);
        }
        for(auto &t : te){
            adj[t].erase(i);
            adj[i].erase(t);
        }
    }


    bitset<100001> gv{};
    for(int i{}; i < q; ++i){
        char c;
        cin >> c;
        if(c == '+' || c == '-'){
            int v;
            cin >> v;
            v--;

            state[v] = 1-state[v];
                for(auto &t : bigadj[v]){
                    if(big[t.F] != -1){
                        sizes[1-state[v]][big[t.F]]--;
                        sides[1-state[v]][big[t.F]].flip(v);
                        sizes[state[v]][big[t.F]]++;
                        sides[state[v]][big[t.F]].flip(v);
                    }
                }
            for(auto [i, c] : adj[v]){
                if(state[i] != state[v]){
                    gv.set(c);
                }else{
                    gv.reset(c);
                }
            }
        }else{
            int lsb = gv._Find_first();
            if(lsb != 100001){
                gv.reset(lsb);
                cout << lsb << '\n';
                adj[edges[lsb][0]].erase(edges[lsb][1]);
                adj[edges[lsb][1]].erase(edges[lsb][0]);
            }else{
                bool found = false;
                for(auto &t : lbig){
                    int st = 1-state[t];
                    int ind = big[t];
                    if(sizes[st][ind] == 0)
                        continue;
                    int a = sides[st][ind]._Find_first();
                    sides[st][ind].reset(a);
                    sizes[st][ind]--;
                    if(big[a] != -1){
                        sides[state[t]][big[a]].reset(t);
                        sizes[state[t]][big[a]]--;
                    }
                    
                    cout << bigadj[t][a] << '\n';
                    found = true;
                    bigadj[a].erase(t);
                    bigadj[t].erase(a);
                    break;
                }
                if(!found){
                    cout << 0 << '\n';
                }
            }
        }
    }
}

uci main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    solve();
}

Details

answer.code: In function ‘void solve()’:
answer.code:36:9: error: ‘bitadj’ was not declared in this scope
   36 |         bitadj[u].set(v);
      |         ^~~~~~