QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#124550#5176. 多控制反转pandapythonerCompile Error//C++146.5kb2023-07-15 05:30:152023-07-15 05:30:19

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-15 05:30:19]
  • 评测
  • [2023-07-15 05:30:15]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define flt double
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()


#ifdef LOCAL
#define _GLIBCXX_DEBUG
bool local = true;
#else
bool local = false;
#endif


mt19937 rnd(234);
const ll inf = 1e18;


struct operation{
    int t, x, y, z;


    operation(){}
    operation(int t, int x, int y = 0, int z = 0) : t(t), x(x), y(y), z(z) {}
};


ostream& operator<<(ostream &out, operation &op){
    out << op.t << " " << op.x;
    if(op.t >= 2){
        out << " " << op.y;
    }
    if(op.t >= 3){
        out << " " << op.z;
    }
    return out;
}


int n, m, Q, subgroup;
vector<operation> rs;


void add_op(int t, int x, int y = 0, int z = 0){
    rs.emplace_back(t, x, y, z);
}


void solve_12(){
    rs.clear();
    add_op(2, 0, n + 1);
    for(int i = 1; i < n; i += 1){
        add_op(3, i, n + i, n + i + 1);
    }
    add_op(2, 2 * n, n);
    for(int i = n - 1; i >= 1; i -= 1){
        add_op(3, i, n + i, n + i + 1);
    }
    add_op(2, 0, n + 1);
}


void add_ops(vector<operation> t){
    for(auto x: t){
        rs.push_back(x);
    }
}


void add_ops_rev(vector<operation> t){
    reverse(all(t));
    for(auto x: t){
        rs.push_back(x);
    }
}


void add_ops_rev_not_last(vector<operation> t){
    t.pop_back();
    reverse(all(t));
    for(auto x: t){
        rs.push_back(x);
    }
}


int cnt_aboba = 0;


void solve(int n, vector<int> a, int dpth){
    if(n == 0){
        add_op(1, a[0]);
        cnt_aboba += 1;
        return;
    }
    if(n == 1){
        add_op(2, a[0], a[1]);
        cnt_aboba += 1;
        return;
    }
    if(n == 2){
        add_op(3, a[0], a[1], a[2]);
        cnt_aboba += 1;
        return;
    }
    int s = n / 2 + 1;
    vector<int> b(s + 2);
    for(int i = 0; i < s; i += 1){
        b[i] = a[i];
    }
    b[s] = a[n + 1];
    b[s + 1] = a[n];
    int t = n - s + 1;
    vector<int> c(t + 2);
    for(int i = 0; i < t - 1; i += 1){
        c[i] = a[n - i - 1];
    }
    c[t - 1] = a[n + 1];
    c[t] = a[n];
    c[t + 1] = a[0];
    solve(s, b, dpth + 1);
    solve(t, c, dpth + 1);
    solve(s, b, dpth + 1);
    solve(t, c, dpth + 1);
}


void get_biba(int s, vector<int> a, vector<int> b, int rs_pos, vector<operation> &rs){
    if(s == 0){
        rs.push_back(operation(1, rs_pos));
        return;
    }
    if(s == 1){
        rs.push_back(operation(2, a[0], rs_pos));
        return;
    }
    if(s == 2){
        rs.push_back(operation(3, a[0], a[1], rs_pos));
        return;
    }
    vector<operation> t;
    t.push_back(operation(3, a[0], a[1], b[0]));
    for(int i = 2; i < s - 1; i += 1){
        t.push_back(operation(3, a[i], b[i - 2], b[i - 1]));
    }
    // vector<operation> rs;
    for(auto x: t){
        rs.push_back(x);
    }
    rs.push_back(operation(3, a[s - 1], b[s - 3], rs_pos));
    reverse(all(t));
    for(auto x: t){
        rs.push_back(x);
    }
}


void solve_fuck(int n, vector<int> a){
    if(n <= 10){
        solve(n, a, 0);
        return;
    }
    int t = 1;
    while((1 << (t + 1)) - 2 < n - t){
        t += 1;
    }
    int s = n - t;
    vector<int> c;
    for(int i = s; i < n; i += 1){
        c.push_back(a[i]);
    }
    c.push_back(a[n + 1]);
    c.push_back(a[n]);
    c.push_back(a[0]);
    vector<operation> biba;
    for(int i = 0; i < t; i += 1){
        biba.push_back(operation(1, c[i]));
    }
    int l = 0;
    vector<int> usd;
    for(int i = 0; i < t; i += 1){
        int mx_sz = (int)usd.size() + 2;
        vector<int> b;
        int r = min(s, l + mx_sz);
        for(int j = l; j < r; j += 1){
            b.push_back(a[j]);
        }
        l = r;
        int sz = (int)b.size();
        get_biba(sz, b, usd, a[s + i], biba);
        for(auto x: b){
            biba.push_back(operatin(1, x));
            usd.push_back(x);
        }
    }
    assert(l == s);
    auto rbiba = biba;
    reverse(all(rbiba));
    /*
    vector<operation> aboba;
    aboba.push_back(operation(2, a[s], a[n + 1]));
    for(auto x: biba){
        tmp.push_back(x);
    }
    for(auto x: aboba){
        tmp.push_back(x);
    }
    reverse(all(biba));
    for(auto x: biba){
        tmp.push_back(x);
    }
    for(int i = 0; i < t; i += 1){
        tmp.push_back(operation(1, c[i]));
    }
    */

    vector<int> d(t + 2);
    for(int i = 0; i < t; i += 1){
        d[i] = a[s + i];
    }

    d[t] = a[n + 1];
    d[t + 1] = a[0];

    for(auto x: biba){
        rs.push_back(x);
    }
    solve(t, d, 0);
    for(auto x: rbiba){
        rs.push_back(x);
    }    

    /*
    for(auto x: tmp){
        rs.push_back(x);
    }
    */
    solve(t + 1, c, 0);


    for(auto x: biba){
        rs.push_back(x);
    }
    solve(t, d, 0);
    for(auto x: rbiba){
        rs.push_back(x);
    }   
    /*
    for(auto x: tmp){
        rs.push_back(x);
    }
    */

    solve(t + 1, c, 0);
}


void solve(){
    rs.clear();
    vector<int> a(m);
    for(int i = 0; i < m; i += 1){
        a[i] = i;
    }
    // shuffle(all(a), rnd);
    cnt_aboba = 0;
    solve_fuck(n, a);
}


vector<int> make_operations(vector<int> t){
    for(auto op: rs){
        if(op.t == 1){
            t[op.x] ^= 1;
        } else if(op.t == 2 && t[op.x]){
            t[op.y] ^= 1;
        } else if(op.t == 3 && t[op.x] && t[op.y]){
            t[op.z] ^= 1;
        }
    }
    return t;
}


int32_t main(){
    if(!local){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
    }
    int t = 1;
    if(local){
        t = 1000;
    }
    while(t--){
        cin >> n >> m >> Q >> subgroup;
        vector<int> t(m);
        if(0){
            for(int i = 0; i < m; i += 1){
                cin >> t[i];
            }
        }
        if(n == 0){
            rs.clear();
            add_op(1, 0);
        } else if(subgroup == 1 || subgroup == 2){
            solve_12();
        } else{
            solve();
        }
        cout << rs.size() << "\n";
        for(auto x: rs){
            cout << x << "\n";
        }
        if(local){
            cout << (flt)(rs.size()) / (flt)(n) << "\n";
        }
        if(0){
            auto nt = make_operations(t);
            for(int i = 0; i < m; i += 1){
                cout << nt[i] << " ";
            }
            cout << "\n";
        }
    }
    return 0;
}



/*
2 6 100 1
0 1 1 0 0 0


*/

详细

answer.code: In function ‘void solve_fuck(int, std::vector<int>)’:
answer.code:196:28: error: ‘operatin’ was not declared in this scope; did you mean ‘operation’?
  196 |             biba.push_back(operatin(1, x));
      |                            ^~~~~~~~
      |                            operation