QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#308471#7181. Graph Cutskevinshan#Compile Error//C++172.5kb2024-01-20 06:33:372024-01-20 06:33:38

Judging History

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

  • [2024-01-20 06:33:38]
  • 评测
  • [2024-01-20 06:33:37]
  • 提交

answer

#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10;
vector<int> adj[maxn], seg[4*maxn];
array<int, 2> e[maxn];
int n, m, q, ban[maxn], in[maxn], qu[maxn], ans[maxn], pref[maxn], no[maxn];
int st[maxn], pos[maxn], sz;
map<int,int> ex;

void add(int val, int l, int r, int id = 1, int lx = 1, int rx = q)
{
    if (lx > r || rx < l) return;
    if (lx >= l && rx <= r) return void(seg[id].emplace_back(val));
    int m = (lx + rx) >> 1;
    add(val, l, r, id<<1, lx, m);
    add(val, l, r, id<<1|1, m+1, rx);
}

inline void rem(int val)
{
    if (!pos[val]) return;
    swap(st[pos[val]], st[sz]);
    pos[st[pos[val]]] = pos[val];
    pos[val] = 0;
    sz--;
}

inline void ins(int val)
{
    if (pos[val]) return;
    st[++sz] = val;
    pos[val] = sz;
}

inline void upd(int i)
{
    for (int id: adj[i]) if (!ban[id])
    {
        int j = e[id][0] ^ e[id][1] ^ i;
        if (in[j]) rem(id), no[id] = 1;
        else ins(id), no[id] = 0;
    }
    in[i] = 1;
}

inline void rupd(int i)
{
    for (int id: adj[i]) if (!ban[id])
    {
        int j = e[id][0] ^ e[id][1] ^ i;
        if (in[j]) ins(id), no[id] = 0;
        else rem(id), no[id] = 1;
    }
    in[i] = 0;
}

void solve(int id = 1, int l = 1, int r = q)
{
    if (!(pref[r] - pref[l-1])) return;
    for (int i: seg[id]) upd(i);
    if (l == r)
    {
        if (qu[l]) 
        {
            ans[l] = sz ? st[sz] : 0;
            if (sz) rem(st[sz]);
            ban[ans[l]] = 1;
        }
        for (int i: seg[id]) rupd(i);
        return;
    }
    int m = (l + r) >> 1;
    solve(id<<1, l, m);
    solve(id<<1|1, m+1, r);
    for (int i: seg[id]) rupd(i);
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    if (fopen("input.in", "r")) {
        freopen("input.in", "r", stdin);
        freopen("output.out", "w", stdout);
    }
    cin>>n>>m;
    for (int i=1; i<=m; i++) cin>>e[i][0]>>e[i][1], adj[e[i][0]].emplace_back(i), adj[e[i][1]].emplace_back(i);
    cin>>q;
    for (int i=1; i<=q; i++)
    {
        char c; int x;
        cin>>c;
        if (c == '?') qu[i] = 1, pref[i] = 1;
        else 
        {
            cin>>x;
            if (!ex.count(x)) ex[x] = i;
            else add(x, ex[x], i-1), ex.erase(x);
        }
        pref[i] += pref[i-1];
    }
    for (auto [u, v]: ex) add(u, v, q);
    if (q > 0) solve();
    for (int i=1; i<=q; i++) if (qu[i] == 1) cout<<ans[i]<<"\n";
}


Details

answer.code: In function ‘int main()’:
answer.code:84:16: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   84 |         freopen("input.in", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
answer.code:85:16: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   85 |         freopen("output.out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/string:43,
                 from /usr/include/c++/13/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:52,
                 from answer.code:3:
/usr/include/c++/13/bits/allocator.h: In destructor ‘std::_Vector_base<int, std::allocator<int> >::_Vector_impl::~_Vector_impl()’:
/usr/include/c++/13/bits/allocator.h:184:7: error: inlining failed in call to ‘always_inline’ ‘std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = int]’: target specific option mismatch
  184 |       ~allocator() _GLIBCXX_NOTHROW { }
      |       ^
In file included from /usr/include/c++/13/vector:66,
                 from /usr/include/c++/13/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:53:
/usr/include/c++/13/bits/stl_vector.h:133:14: note: called from here
  133 |       struct _Vector_impl
      |              ^~~~~~~~~~~~