QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#431386#7979. 棋盘_LAP_Compile Error//C++143.6kb2024-06-05 14:09:012024-06-05 14:09:02

Judging History

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

  • [2024-06-05 14:09:02]
  • 评测
  • [2024-06-05 14:09:01]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

struct Bigint {
    vector<int> v;
    inline const int size() const {return v.size(); }
    inline void flatten() {
        for(int i = 1; i < v.size(); i ++) {
            if(v[i - 1] >= 10) v[i] += v[i - 1] / 10, v[i - 1] %= 10;
        }
        while(v.size() > 1 && v.back() == 0) v.pop_back();
        while(v.back() >= 10) {
            int x = v.back() / 10; v.back() %= 10;
            v.emplace_back(x);
        }
    }
    Bigint(unsigned long long x = 0) {
        v.clear();
        do {
            v.emplace_back(x % 10);
            x /= 10;
        } while(x);
    }
    Bigint(const string &str) {
        v.resize(str.size());
        for(int i = 0; i < str.size(); i ++)
            v[i] = str[i] - '0';
    }
};
Bigint operator + (const Bigint &lhs, const Bigint &rhs) {
    Bigint res = lhs; int siz = max(lhs.size(), rhs.size());
    res.v.resize(siz, 0);
    for(int i = 0; i < rhs.size(); i ++) res.v[i] += rhs.v[i];
    res.flatten(); return res;
}
Bigint operator - (const Bigint &lhs, const Bigint &rhs) {
    Bigint res = lhs; int siz = max(lhs.size(), rhs.size());
    res.v.resize(siz, 0);
    for(int i = 0; i < rhs.size(); i ++) {
        res.v[i] -= rhs.v[i];
        while(res.v[i] < 0) res.v[i] += 10, res.v[i + 1] --;
    }
    res.flatten(); return res;
}
bool operator == (const Bigint &lhs, const Bigint &rhs) {
    if(lhs.size() != rhs.size()) return false;
    for(int i = 0; i < lhs.size(); i ++)
        if(lhs.v[i] != rhs.v[i]) return false;
    return true;
}
bool operator < (const Bigint &lhs, const Bigint &rhs) {
    if(lhs.size() != rhs.size()) return lhs.size() < rhs.size();
    for(int i = lhs.size() - 1; i >= 0; i --)
        if(lhs.v[i] != rhs.v[i]) return lhs.v[i] < rhs.v[i];
    return false;
}
bool operator > (const Bigint &lhs, const Bigint &rhs) {
    if(lhs.size() != rhs.size()) return lhs.size() > rhs.size();
    for(int i = lhs.size() - 1; i >= 0; i --)
        if(lhs.v[i] != rhs.v[i]) return lhs.v[i] > rhs.v[i];
    return false;
}
bool operator >= (const Bigint &lhs, const Bigint &rhs) {return lhs > rhs || lhs == rhs; }
bool operator <= (const Bigint &lhs, const Bigint &rhs) {return lhs < rhs || lhs == rhs; }

ostream& operator << (ostream &out, const Bigint &x) {
    for(int i = x.size() - 1; i >= 0; i --)
        out << x.v[i];
    return out;
}

int k, q, x, y;
Bigint maxv;
vector<Bigint> fib; int tot;
vector<pair<int, int>> vis;

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    fib.emplace_back(Bigint(0)), fib.emplace_back(Bigint(1));

    cin >> k >> q >> x >> y;
    maxv.v.resize(k + 1, 0), maxv.v.back() = 1; tot = 1;
    while(fib.back() <= maxv) 
        fib.emplace_back(fib[tot - 1] + fib[tot]), tot ++;
    fib.pop_back(), tot --; pos.resize(fib.size());
    for(int i = 1; i <= tot; i += 2) {
        vis.push_back({i + 1 >> 1, i + 1 >> 1});
        vis.push_back({(i + 1 >> 1) + 1, i + 1 >> 1});
        if(i + 1 <= tot) {
            vis.push_back({i + 1 >> 1, (i + 1 >> 1) + 1});
            vis.push_back({i + 1 >> 1, (i + 1 >> 1) + 2});
        }
    }

    cout << vis.size() << '\n';
    for(auto pr : vis) cout << pr.first << ' ' << pr.second << '\n';
    while(q --) {
        string str; cin >> str;
        static char ans[(int)1e5];
        Bigint val(str);
        for(int i = 0; i < vis.size(); i ++) ans[i] = '0';
        for(int i = tot; i >= 1; i --) 
            if(val >= fib[i]) val = val - fib[i], ans[i * 2] = '1';
        for(int i = 0; i < vis.size(); i ++)
            cout << ans[i];
        cout << '\n';
    }


    return 0;
}

詳細信息

answer.code: In function ‘int main()’:
answer.code:86:29: error: ‘pos’ was not declared in this scope; did you mean ‘pow’?
   86 |     fib.pop_back(), tot --; pos.resize(fib.size());
      |                             ^~~
      |                             pow