QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#677758#9519. Build a Computerucup-team055#AC ✓0ms3812kbC++202.9kb2024-10-26 13:22:162024-10-26 13:22:19

Judging History

This is the latest submission verdict.

  • [2024-10-26 13:22:19]
  • Judged
  • Verdict: AC
  • Time: 0ms
  • Memory: 3812kb
  • [2024-10-26 13:22:16]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
const ll ILL=2167167167167167167;
const int INF=2100000000;
#define rep(i,a,b) for (int i=(int)(a);i<(int)(b);i++)
#define all(p) p.begin(),p.end()
template<class T> using _pq = priority_queue<T, vector<T>, greater<T>>;
template<class T> ll LB(vector<T> &v,T a){return lower_bound(v.begin(),v.end(),a)-v.begin();}
template<class T> ll UB(vector<T> &v,T a){return upper_bound(v.begin(),v.end(),a)-v.begin();}
template<class T> bool chmin(T &a,T b){if(a>b){a=b;return 1;}else return 0;}
template<class T> bool chmax(T &a,T b){if(a<b){a=b;return 1;}else return 0;}
template<class T> void So(vector<T> &v) {sort(v.begin(),v.end());}
template<class T> void Sore(vector<T> &v) {sort(v.begin(),v.end(),[](T x,T y){return x>y;});}
bool yneos(bool a,bool upp=0){if(a){cout<<(upp?"YES\n":"Yes\n");}else{cout<<(upp?"NO\n":"No\n");}return a;}
template<class T> void vec_out(vector<T> &p,int ty=0){
    if(ty==2){cout<<'{';for(int i=0;i<(int)p.size();i++){if(i){cout<<",";}cout<<'"'<<p[i]<<'"';}cout<<"}\n";}
    else{if(ty==1){cout<<p.size()<<"\n";}for(int i=0;i<(int)(p.size());i++){if(i) cout<<" ";cout<<p[i];}cout<<"\n";}}
template<class T> T vec_min(vector<T> &a){assert(!a.empty());T ans=a[0];for(auto &x:a) chmin(ans,x);return ans;}
template<class T> T vec_max(vector<T> &a){assert(!a.empty());T ans=a[0];for(auto &x:a) chmax(ans,x);return ans;}
template<class T> T vec_sum(vector<T> &a){T ans=T(0);for(auto &x:a) ans+=x;return ans;}
int pop_count(long long a){int res=0;while(a){res+=(a&1),a>>=1;}return res;}
template<class T> bool inside(T l,T x,T r){return l<=x&&x<r;}



void solve();
// CYAN / FREDERIC
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
    // cin >> t;
    rep(i, 0, t) solve();
}

void solve(){
    int L, R;
    cin >> L >> R;
    map<pair<int, int>, int> m;
    vector<pair<int, int>> p;
    R++;
    m[{L, R}] = 1;
    m[{-1, -1}] = 0;
    vector<vector<pair<int, int>>> G(2);
    p.push_back({-1, -1});
    p.push_back({L, R});
    auto add = [&](int l, int r) -> int {
        auto tmp = make_pair(l, r);
        if (m.count(tmp)) return m[tmp];
        G.push_back({});
        m[tmp] = m.size();
        p.push_back(tmp);
        return m[tmp];
    };
    rep(rp, 1, p.size()){
        int X, Y;
        tie(X, Y) = p[rp];
        if (X == 1){
            int ind = add(-1, -1);
            G[ind].push_back({rp, 1});
            X++;
        }
        rep(d, 0, 2){
            int a = (X + 1 - d) / 2;
            int b = (Y + 1 - d) / 2;
            if (a == b) continue;
            int ind = add(a, b);
            G[ind].push_back({rp, d});
        }
    }
    cout << G.size() << "\n";
    for (auto x : G){
        cout << x.size();
        for (auto y : x){
            cout << " " << y.first + 1 << " " << y.second;
        }
        cout << "\n";
    }
}

这程序好像有点Bug,我给组数据试试?

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3596kb

input:

5 7

output:

5
1 5 1
0
1 2 0
1 2 1
3 3 1 4 0 4 1

result:

ok ok

Test #2:

score: 0
Accepted
time: 0ms
memory: 3812kb

input:

10 27

output:

9
3 7 1 8 1 9 1
0
2 2 0 2 1
1 3 0
1 3 1
1 4 0
2 4 1 5 1
1 5 0
5 6 0 6 1 7 0 8 0 8 1

result:

ok ok

Test #3:

score: 0
Accepted
time: 0ms
memory: 3532kb

input:

5 13

output:

8
3 6 1 7 1 8 1
0
1 2 0
1 2 1
1 3 0
2 3 1 4 1
1 4 0
5 5 0 5 1 6 0 7 0 7 1

result:

ok ok

Test #4:

score: 0
Accepted
time: 0ms
memory: 3636kb

input:

1 1000000

output:

39
38 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1
0
1 2 0
1 2 1
1 3 0
3 3 1 4 0 4 1
1 5 0
3 5 1 6 0 6 1
1 7 0
3 7 1 8 0 8 1
1 9 0
3 9 1 10 0 10 1
1 11 0
3 11 1 12...

result:

ok ok

Test #5:

score: 0
Accepted
time: 0ms
memory: 3576kb

input:

1 1

output:

2
1 2 1
0

result:

ok ok

Test #6:

score: 0
Accepted
time: 0ms
memory: 3588kb

input:

7 9

output:

6
1 6 1
0
1 2 0
1 2 1
2 3 0 4 0
2 4 1 5 0

result:

ok ok

Test #7:

score: 0
Accepted
time: 0ms
memory: 3600kb

input:

3 7

output:

5
2 4 1 5 1
0
1 2 0
1 2 1
4 3 0 3 1 4 0 4 1

result:

ok ok

Test #8:

score: 0
Accepted
time: 0ms
memory: 3732kb

input:

1 5

output:

4
3 2 1 3 1 4 1
0
2 2 0 2 1
1 3 0

result:

ok ok

Test #9:

score: 0
Accepted
time: 0ms
memory: 3800kb

input:

1 4

output:

4
3 2 1 3 1 4 1
0
1 2 0
2 2 1 3 0

result:

ok ok

Test #10:

score: 0
Accepted
time: 0ms
memory: 3800kb

input:

8 9

output:

5
1 5 1
0
2 2 0 2 1
1 3 0
1 4 0

result:

ok ok

Test #11:

score: 0
Accepted
time: 0ms
memory: 3520kb

input:

7 51

output:

11
6 6 1 7 1 8 1 9 1 10 1 11 1
0
1 2 0
1 2 1
3 3 0 3 1 4 0
1 4 1
2 5 0 6 0
2 5 1 6 1
1 7 0
3 7 1 8 0 8 1
3 9 0 9 1 10 0

result:

ok ok

Test #12:

score: 0
Accepted
time: 0ms
memory: 3808kb

input:

51 79

output:

12
1 12 1
0
1 2 0
1 2 1
3 3 0 3 1 4 0
1 4 1
1 5 0
3 5 1 6 0 6 1
1 7 0
3 7 1 8 0 8 1
2 9 0 10 0
2 10 1 11 0

result:

ok ok

Test #13:

score: 0
Accepted
time: 0ms
memory: 3588kb

input:

92 99

output:

11
1 11 1
0
2 2 0 2 1
2 3 0 3 1
1 4 0
1 4 1
1 5 0
1 6 1
1 7 0
1 8 1
2 9 1 10 0

result:

ok ok

Test #14:

score: 0
Accepted
time: 0ms
memory: 3532kb

input:

27 36

output:

12
1 12 1
0
1 2 0
1 2 1
1 3 0
2 3 1 4 0
1 4 1
2 5 0 6 0
2 5 1 7 0
2 6 1 7 1
2 8 0 9 0
3 9 1 10 1 11 0

result:

ok ok

Test #15:

score: 0
Accepted
time: 0ms
memory: 3604kb

input:

55 84

output:

15
1 15 1
0
1 2 0
1 2 1
1 3 0
2 3 1 4 0
1 4 1
4 5 0 5 1 6 0 7 0
1 6 1
1 7 1
1 8 0
4 8 1 9 1 10 0 10 1
1 9 0
4 11 0 11 1 12 0 13 0
2 12 1 14 0

result:

ok ok

Test #16:

score: 0
Accepted
time: 0ms
memory: 3744kb

input:

297208 929600

output:

54
3 52 1 53 1 54 1
0
1 2 0
1 2 1
1 3 0
3 3 1 4 0 4 1
1 5 0
3 5 1 6 0 6 1
1 7 0
2 7 1 8 1
1 8 0
1 9 0
4 9 1 10 0 11 0 11 1
1 10 1
1 12 0
4 12 1 13 0 13 1 14 0
1 14 1
4 15 0 15 1 16 0 17 0
1 16 1
1 17 1
1 18 0
4 18 1 19 0 19 1 20 0
1 20 1
2 21 0 22 0
2 21 1 23 0
2 22 1 23 1
1 24 0
4 24 1 25 0 25 1 26...

result:

ok ok

Test #17:

score: 0
Accepted
time: 0ms
memory: 3488kb

input:

45728 589156

output:

48
8 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1
0
1 2 0
1 2 1
1 3 0
3 3 1 4 0 4 1
3 5 0 5 1 6 0
1 6 1
1 7 0
3 7 1 8 0 8 1
1 9 0
3 9 1 10 0 10 1
2 11 0 12 0
1 11 1
1 12 1
1 13 0
4 13 1 14 0 14 1 15 0
1 15 1
2 16 0 17 0
2 16 1 18 0
2 17 1 18 1
2 19 0 20 0
2 19 1 21 0
2 20 1 21 1
2 22 0 23 0
2 22 1 24 0
2...

result:

ok ok

Test #18:

score: 0
Accepted
time: 0ms
memory: 3536kb

input:

129152 138000

output:

40
1 40 1
0
1 2 0
1 2 1
1 3 0
3 3 1 4 0 4 1
1 5 0
3 5 1 6 0 6 1
1 7 0
3 7 1 8 0 8 1
3 9 0 9 1 10 0
1 10 1
1 11 0
3 11 1 12 0 12 1
1 13 0
3 13 1 14 0 14 1
1 15 0
2 15 1 16 1
1 16 0
2 17 0 19 0
2 17 1 18 0
2 18 1 19 1
1 20 0
4 20 1 21 0 21 1 22 0
1 22 1
1 23 0
4 23 1 24 1 25 0 25 1
1 24 0
4 26 0 26 1 ...

result:

ok ok

Test #19:

score: 0
Accepted
time: 0ms
memory: 3592kb

input:

245280 654141

output:

49
4 46 1 47 1 48 1 49 1
0
2 2 0 2 1
1 3 0
1 3 1
3 4 0 4 1 5 0
1 5 1
3 6 0 6 1 7 0
1 7 1
3 8 0 8 1 9 0
1 9 1
2 10 0 11 0
1 10 1
1 11 1
1 12 0
4 12 1 13 1 14 0 14 1
1 13 0
1 15 0
4 15 1 16 0 16 1 17 1
1 17 0
1 18 0
4 18 1 19 0 20 0 20 1
1 19 1
4 21 0 21 1 22 0 23 0
1 22 1
1 23 1
2 24 0 25 0
2 24 1 26...

result:

ok ok

Test #20:

score: 0
Accepted
time: 0ms
memory: 3484kb

input:

202985 296000

output:

49
1 49 1
0
1 2 0
1 2 1
1 3 0
3 3 1 4 0 4 1
1 5 0
3 5 1 6 0 6 1
1 7 0
2 7 1 8 0
1 8 1
1 9 0
4 9 1 10 1 11 0 11 1
1 10 0
1 12 0
4 12 1 13 0 14 0 14 1
1 13 1
4 15 0 15 1 16 0 17 0
1 16 1
1 17 1
1 18 0
4 18 1 19 0 19 1 20 0
1 20 1
1 21 0
4 21 1 22 1 23 0 23 1
1 22 0
1 24 0
4 24 1 25 0 25 1 26 1
1 26 0
...

result:

ok ok

Test #21:

score: 0
Accepted
time: 0ms
memory: 3612kb

input:

438671 951305

output:

56
2 54 1 56 1
0
1 2 0
1 2 1
2 3 0 4 0
1 3 1
1 4 1
1 5 0
4 5 1 6 0 6 1 7 0
1 7 1
4 8 0 8 1 9 0 10 0
1 9 1
1 10 1
1 11 0
4 11 1 12 1 13 0 13 1
1 12 0
1 14 0
4 14 1 15 0 15 1 16 1
1 16 0
1 17 0
4 17 1 18 0 18 1 19 1
1 19 0
1 20 0
4 20 1 21 0 22 0 22 1
1 21 1
1 23 0
4 23 1 24 0 24 1 25 0
1 25 1
1 26 0
...

result:

ok ok

Test #22:

score: 0
Accepted
time: 0ms
memory: 3608kb

input:

425249 739633

output:

55
2 54 1 55 1
0
1 2 0
1 2 1
1 3 0
2 3 1 4 1
1 4 0
1 5 0
4 5 1 6 0 6 1 7 1
1 7 0
1 8 0
4 8 1 9 0 9 1 10 1
1 10 0
1 11 0
4 11 1 12 0 13 0 13 1
1 12 1
4 14 0 14 1 15 0 16 0
1 15 1
1 16 1
1 17 0
4 17 1 18 1 19 0 19 1
1 18 0
1 20 0
4 20 1 21 0 21 1 22 1
1 22 0
4 23 0 23 1 24 0 25 0
1 24 1
1 25 1
1 26 0
...

result:

ok ok

Test #23:

score: 0
Accepted
time: 0ms
memory: 3484kb

input:

551207 961718

output:

53
1 53 1
0
1 2 0
1 2 1
3 3 0 3 1 4 0
1 4 1
3 5 0 5 1 6 0
1 6 1
1 7 0
3 7 1 8 0 8 1
1 9 0
2 9 1 10 0
1 10 1
4 11 0 11 1 12 0 13 0
1 12 1
1 13 1
1 14 0
4 14 1 15 1 16 0 16 1
1 15 0
1 17 0
4 17 1 18 0 19 0 19 1
1 18 1
2 20 0 21 0
2 20 1 22 0
2 21 1 22 1
1 23 0
4 23 1 24 1 25 0 25 1
1 24 0
2 26 0 28 0
...

result:

ok ok

Test #24:

score: 0
Accepted
time: 0ms
memory: 3536kb

input:

114691 598186

output:

51
5 47 1 48 1 49 1 50 1 51 1
0
1 2 0
1 2 1
3 3 0 3 1 4 0
1 4 1
1 5 0
3 5 1 6 0 6 1
1 7 0
2 7 1 8 0
1 8 1
1 9 0
4 9 1 10 1 11 0 11 1
1 10 0
1 12 0
4 12 1 13 0 14 0 14 1
1 13 1
1 15 0
4 15 1 16 1 17 0 17 1
1 16 0
1 18 0
4 18 1 19 0 20 0 20 1
1 19 1
1 21 0
4 21 1 22 1 23 0 23 1
1 22 0
1 24 0
4 24 1 25...

result:

ok ok

Test #25:

score: 0
Accepted
time: 0ms
memory: 3532kb

input:

234654 253129

output:

44
1 44 1
0
2 2 0 2 1
1 3 0
1 3 1
1 4 0
2 4 1 5 0
1 5 1
4 6 0 6 1 7 0 8 0
1 7 1
1 8 1
1 9 0
4 9 1 10 0 10 1 11 0
1 11 1
1 12 0
4 12 1 13 1 14 0 14 1
1 13 0
2 15 0 17 0
2 15 1 16 0
2 16 1 17 1
4 18 0 18 1 19 0 20 0
1 19 1
1 20 1
1 21 0
4 21 1 22 1 23 0 23 1
1 22 0
1 24 0
4 24 1 25 0 25 1 26 1
1 26 0
...

result:

ok ok

Test #26:

score: 0
Accepted
time: 0ms
memory: 3552kb

input:

554090 608599

output:

48
1 48 1
0
2 2 0 2 1
1 3 0
1 3 1
1 4 0
3 4 1 5 0 5 1
2 6 0 7 0
1 6 1
1 7 1
2 8 0 9 0
2 8 1 10 0
2 9 1 10 1
2 11 0 12 0
2 11 1 13 0
2 12 1 13 1
4 14 0 14 1 15 0 16 0
1 15 1
1 16 1
1 17 0
4 17 1 18 1 19 0 19 1
1 18 0
2 20 0 22 0
2 20 1 21 0
2 21 1 22 1
1 23 0
4 23 1 24 1 25 0 25 1
1 24 0
2 26 0 28 0
...

result:

ok ok

Extra Test:

score: 0
Extra Test Passed