QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#510115#9156. 百万富翁AntekbCompile Error//C++145.1kb2024-08-08 21:16:052024-08-08 21:16:09

Judging History

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

  • [2024-08-08 21:16:09]
  • 评测
  • [2024-08-08 21:16:05]
  • 提交

answer

#include "bits/stdc++.h"	/** keep-include */
using namespace std;

#define rep(i, b, e) for(int i = (b); i <= (e); i++)
#define per(i, b, e) for(int i = (e); i >= (b); i--)
#define FOR(i, b, e) rep(i, b, (e) - 1)
#define SZ(x) int(x.size())
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define st first
#define nd second
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;

auto &operator<<(auto &o, pair<auto, auto> p) {
	return o << "(" << p.st << ", " << p.nd << ")"; }
auto operator<<(auto &o, auto x)->decltype(end(x), o) {
	o << "{"; int i=0; for(auto e: x) o << ", " + 2*!i++ << e;
	return o << "}"; }
#ifdef LOCAL
#define deb(x...) cerr << "[" #x "]: ", [](auto...$) { \
	((cerr << $ << "; "),...) << endl; }(x)
#else
#define deb(...)
#endif

const int N=2005;

bool good(vector<int> V, vector<vector<vi> > &common){
    for(int i=0; i<V.size(); i++)
    {
        int a=V[i], b=V[(i+1)%V.size()], c=V[(i+2)%V.size()];
        for(int j:common[a][b]){
            if(binary_search(all(common[b][c]), j)){
                return 0;
            }
        }
    }
    return 1;
}

bool good2(vector<int> V, vector<vector<vi> > &common){
    for(int i=0; i<V.size()-2; i++)
    {
        int a=V[i], b=V[i+1], c=V[i+2];
        assert(common[a][b].size()<=1);
        for(int j:common[a][b]){
            if(binary_search(all(common[b][c]), j)){
                return 0;
            }
        }
    }
    return 1;
}


void solve() {
    int n, m;
    cin>>n>>m;
    vector<vi> V(m);
    vector<vector<vi> > common(n, vector<vi>(n, vi(0)));
    vector<bitset<N> > kto(m);
    vector<vi> kluby(n);
    vector<set<int>> rozm(n+1);
    vi siz(m);
    int maks=0;
    for(int i=0; i<m; i++){
        int k;
        cin>>k;
        maks=max(maks, k);
        V[i].resize(k);
        for(int &j:V[i]){
            cin>>j;
            j--;
            kluby[j].pb(i);
            kto[i][j]=1; 
        }
        siz[i]=k;
        rozm[k].insert(i);
        for(int &j:V[i]){
            for(int &l:V[i]){
                common[j][l].pb(i);
            }
        }
    }
    if(maks>(2*n)/3){
        cout<<-1<<"\n";
        return;
    }
    vector<int> kol;
    for(int ii=1; ii<=n; ii++){
        deb(V, kol);
        bitset<N> zle;
        zle.flip();
        for(int j:kol)zle[j]=0;
        if(ii<=n-3){
            for(int i:rozm[(2*(n-ii))/3+1]){
                zle&=kto[i];
            }
        }
        assert(zle.any());
        int t=zle._Find_first();
        kol.pb(t);
        for(int i:kluby[t]){
            kto[i][t]=0;
            siz[i]--;
            int pop=siz[i];
            rozm[pop].insert(i);
            rozm[pop+1].erase(i);
        }
    }
    vector<int> dobre;
    for(int i=0; i<3; i++){
        dobre.pb(kol.back());
        kol.pop_back();
    }
    while(kol.size()){
        deb(kol, dobre);
        bool ok=0;
        if(dobre.size()<10){
            for(int i=0; i<dobre.size(); i++){
                deb("b");
                vector<int> dobre2;
                dobre2=dobre;
                rotate(dobre2.begin(), dobre2.begin()+i, dobre2.end());
                dobre2.pb(kol.back());
                rotate(dobre2.begin(), dobre2.end()-1, dobre2.end());
                auto it=dobre2.begin(), it2=dobre2.begin()+3;
                if(dobre2.size()<3)it2=dobre2.end();
                sort(it, it2);
                deb("a");
                while(true){
                    if(good(dobre2, common)){
                        ok=1;
                        break;
                    }
                    if(!next_permutation(it, it2))break;
                }
                if(ok==1){
                    dobre=dobre2;
                    break;
                }
            }
        }
        else{
            vector<int> V(7);
            for(int i=0; i<dobre.size(); i++){
                for(int k=-2; k<=3; k++){
                    V[2+k+(k>=0)]=dobre[(i+dobre.size()+k)%dobre.size()];
                }
                V[2]=kol.back();
                deb(dobre, i, V);
                auto it=V.begin()+2, it2=V.begin()+5;
                sort(it, it2);
                while(true){
                    if(good2(V, common)){
                        ok=1;
                        break;
                    }
                    if(!next_permutation(it, it2))break;
                }
                if(ok==1){
                    deb(dobre, V);
                    for(int k=-2; k<=3; k++){
                        dobre[(i+dobre.size()+k)%dobre.size()]=V[k+2];
                    }
                    deb(dobre);
                    dobre.insert(dobre.begin()+(i+4)%int(dobre.size()), V.back());
                    deb(dobre);
                    break;
                }
            }
        }
        assert(ok==1);
        kol.pop_back();
    }
    assert(good(dobre, common));
    for(int i:dobre){
        cout<<i+1<<" ";
    }
    cout<<"\n";
}

int main() {
	cin.tie(0)->sync_with_stdio(0);
	int tt = 1;
    cin>>tt;
	FOR(te, 0, tt) solve();
	return 0;
}

Details

answer.code:17:18: warning: use of ‘auto’ in parameter declaration only available with ‘-std=c++20’ or ‘-fconcepts’
   17 | auto &operator<<(auto &o, pair<auto, auto> p) {
      |                  ^~~~
answer.code:17:32: warning: use of ‘auto’ in parameter declaration only available with ‘-std=c++20’ or ‘-fconcepts’
   17 | auto &operator<<(auto &o, pair<auto, auto> p) {
      |                                ^~~~
answer.code:17:38: warning: use of ‘auto’ in parameter declaration only available with ‘-std=c++20’ or ‘-fconcepts’
   17 | auto &operator<<(auto &o, pair<auto, auto> p) {
      |                                      ^~~~
answer.code:19:17: warning: use of ‘auto’ in parameter declaration only available with ‘-std=c++20’ or ‘-fconcepts’
   19 | auto operator<<(auto &o, auto x)->decltype(end(x), o) {
      |                 ^~~~
answer.code:19:26: warning: use of ‘auto’ in parameter declaration only available with ‘-std=c++20’ or ‘-fconcepts’
   19 | auto operator<<(auto &o, auto x)->decltype(end(x), o) {
      |                          ^~~~
/usr/bin/ld: /tmp/ccOJBo5W.o: in function `main':
answer.code:(.text.startup+0x0): multiple definition of `main'; /tmp/ccPwS6cW.o:implementer.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccPwS6cW.o: in function `main':
implementer.cpp:(.text.startup+0x1df): undefined reference to `richest(int, int, int)'
collect2: error: ld returned 1 exit status