QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#783267#6255. Conveyor Belts353cerega#TL 0ms0kbC++142.3kb2024-11-26 05:47:012024-11-26 05:47:02

Judging History

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

  • [2024-11-26 05:47:02]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-11-26 05:47:01]
  • 提交

answer

//#pragma GCC optimize("Ofast", "unroll-loops", "omit-frame-pointer","inline")
//#pragma GCC option("arch=native","tune=native","no-zero-upper")
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;

#define X first
#define Y second


const ll mod = 1000000007;
//const ll mod = 998244353;



ll pew(ll a, ll b) {
    ll res = 1;
    while (b>0) {
        if (b&1) res = res*a%mod;
        b >>= 1;
        a = a*a%mod;
    }
    return res;
}



const ll K = 32;

void solve() {
    ll A, B;
    cin >> A >> B;
    cin >> A >> B;
    int sz = 1;
    vector<vector<int>> ans(300);
    vector<int> prv(2,0);
    vector<ll> W = {A, A+B};
    for (ll i=K-1;i>=0;i--) {
        vector<int> nxt(2,-3);
        if (i==0) nxt[0] = -2, nxt[1] = 0;
        for (int j=0;j<2;j++) {
            if (j+1<2 and W[j]/(1LL<<(i+1))==W[j+1]/(1LL<<(i+1))) continue;
            ll x = W[j]/(1LL<<(i+1))*(1LL<<(i+1));
            int u = sz++, v = sz++;
            ans[prv[j]] = {u,v};
            vector<ll> d(2,-3);
            for (ll b=0;b<2;b++) {
                ll x2 = x+b*(1LL<<i);
                if (x2/(1LL<<i)<W[0]/(1LL<<i)) d[b] = -1;
                if (x2/(1LL<<i)>W[0]/(1LL<<i) and x2/(1LL<<i)<W[1]/(1LL<<i)) d[b] = -2;
                if (x2/(1LL<<i)>W[1]/(1LL<<i)) d[b] = 0;
                if (d[b]!=-3) continue;
                if (x2/(1LL<<i)==W[1]/(1LL<<i)) {
                    if (nxt[1]==-3) nxt[1] = sz++;
                    d[b] = nxt[1];
                    continue;
                }
                if (x2/(1LL<<i)==W[0]/(1LL<<i)) {
                    if (nxt[0]==-3) nxt[0] = sz++;
                    d[b] = nxt[0];
                }
            }
            ans[u] = {0,d[0]};
            ans[v] = {d[1],0};
        }
        prv = nxt;
    }
    for (int i=0;i<sz;i++) {
        if (ans[i][0]==ans[i][1]) {
            assert(ans[i][0]==0);
            ans[i][1] = sz;
        }
    }
    ans[sz] = ans[0];
    sz++;
    cout << sz << "\n";
    for (int i=0;i<sz;i++) {
        cout << ans[i][0] << " " << ans[i][1] << "\n";
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    int T = 1;
    //cin >> T;
    while (T--) solve();
    return 0;
}

详细

Test #1:

score: 0
Checker Time Limit Exceeded

input:

2 3
3 2

output:

103
1 2
0 3
0 102
4 5
0 6
0 102
7 8
0 9
0 102
10 11
0 12
0 102
13 14
0 15
0 102
16 17
0 18
0 102
19 20
0 21
0 102
22 23
0 24
0 102
25 26
0 27
0 102
28 29
0 30
0 102
31 32
0 33
0 102
34 35
0 36
0 102
37 38
0 39
0 102
40 41
0 42
0 102
43 44
0 45
0 102
46 47
0 48
0 102
49 50
0 51
0 102
52 53
0 54
0 102...

result: