QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#100711#6319. Parallel Processing (Easy)SolitaryDream#AC ✓275ms34284kbC++202.7kb2023-04-27 18:03:582023-04-27 18:04:59

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-27 18:04:59]
  • 评测
  • 测评结果:AC
  • 用时:275ms
  • 内存:34284kb
  • [2023-04-27 18:03:58]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define FOR(i,s,t) for(int i=(s),_t=(t); i<=_t; ++i)
#define DOR(i,s,t) for(int i=(s),_t=(t); i>=_t; --i)
typedef long long ll;
const int Mod=7000009;
bool mark[Mod];
int Hash(const vector<int> &v) {
    int w=0;
    for(auto x: v) w=(w*233+x)%Mod;
    return w;
}
struct node {
    int a,b;
};
struct state {
    vector<int> lp;
    vector<vector<node>> ans;
};
void print(vector<vector<node>> ans) {
    cout << ans.size() << '\n';
    for(auto s: ans) {
        FOR(i,0,3) {
            int j=min(i,(int)s.size()-1);
            cout << s[j].b << ' ' << s[j].a << ' ' << s[j].b << '\n';
        }
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    if(n<=9)
    {
        state q;
        q.lp={0};
        FOR(i,1,n) q.lp.push_back(i);
        vector<vector<int>> f;
        FOR(i,2,n) FOR(j,i+1,n) FOR(k,j+1,n) FOR(h,k+1,n) f.push_back({i,j,k,h});
        FOR(i,2,n) FOR(j,i+1,n) FOR(k,j+1,n) f.push_back({i,j,k});
        FOR(i,2,n) FOR(j,i+1,n) f.push_back({i,j});
        FOR(i,2,n) f.push_back({i});
        queue<state> Q;
        mark[Hash(q.lp)]=1;
        Q.push(q);
        while(!Q.empty()) {
            q=Q.front(),Q.pop();
            for(auto v: f) {
                state nq=q;
                vector<node> op;
                int w=1;
                for(auto x: v) {
                    if(q.lp[x]>1) {
                        nq.lp[x]=q.lp[q.lp[x]-1];
                        op.push_back({q.lp[x]-1,x});
                    } else {
                        w=0;
                        break;
                    }
                }
                if(!w) continue;
                w=1;
                FOR(i,1,n) if(nq.lp[i]!=1) {w=0;break;}
                nq.ans.push_back(op);
                if(w) {
                    print(nq.ans);
                    return 0;
                }
                if(mark[Hash(nq.lp)]) continue;
                mark[Hash(nq.lp)]=1;
                Q.push(nq);
            }
        }
    }
    else if(n<=11)
    {
        printf("4\n2 1 2\n4 3 4\n6 5 6\n8 7 8\n3 2 3\n4 2 4\n8 6 8\n10 9 10\n5 4 5\n6 4 6\n8 4 8\n11 10 11\n7 6 7\n9 8 9\n10 8 10\n11 8 11\n");
    }
    else if(n<=13)
    {
        printf("5\n2 1 2\n5 4 5\n8 7 8\n11 10 11\n3 2 3\n6 5 6\n9 8 9\n12 11 12\n5 3 5\n6 3 6\n8 6 8\n12 9 12\n4 3 4\n7 6 7\n9 6 9\n12 6 12\n8 3 8\n10 9 10\n11 9 11\n13 12 13\n");
    }
    else
    {
        printf("6\n2 1 2\n4 3 4\n6 5 6\n9 8 9\n4 2 4\n7 6 7\n10 9 10\n15 14 15\n5 4 5\n7 4 7\n11 10 11\n16 15 16\n9 7 9\n10 7 10\n11 7 11\n13 12 13\n3 2 3\n6 4 6\n12 11 12\n13 11 13\n8 7 8\n14 13 14\n15 13 15\n16 13 16\n");
    }
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 2ms
memory: 3312kb

input:

2

output:

1
2 1 2
2 1 2
2 1 2
2 1 2

result:

ok AC

Test #2:

score: 0
Accepted
time: 2ms
memory: 3296kb

input:

4

output:

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

result:

ok AC

Test #3:

score: 0
Accepted
time: 2ms
memory: 3372kb

input:

3

output:

2
2 1 2
3 2 3
3 2 3
3 2 3
3 1 3
3 1 3
3 1 3
3 1 3

result:

ok AC

Test #4:

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

input:

5

output:

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

result:

ok AC

Test #5:

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

input:

6

output:

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

result:

ok AC

Test #6:

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

input:

7

output:

3
2 1 2
3 2 3
4 3 4
6 5 6
3 1 3
4 2 4
5 4 5
7 6 7
5 2 5
6 4 6
7 4 7
7 4 7

result:

ok AC

Test #7:

score: 0
Accepted
time: 16ms
memory: 8188kb

input:

8

output:

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

result:

ok AC

Test #8:

score: 0
Accepted
time: 275ms
memory: 34284kb

input:

9

output:

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

result:

ok AC

Test #9:

score: 0
Accepted
time: 2ms
memory: 3372kb

input:

10

output:

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

result:

ok AC

Test #10:

score: 0
Accepted
time: 1ms
memory: 3360kb

input:

11

output:

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

result:

ok AC

Test #11:

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

input:

12

output:

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

result:

ok AC

Test #12:

score: 0
Accepted
time: 2ms
memory: 3452kb

input:

13

output:

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

result:

ok AC

Test #13:

score: 0
Accepted
time: 2ms
memory: 3372kb

input:

14

output:

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

result:

ok AC

Test #14:

score: 0
Accepted
time: 2ms
memory: 3344kb

input:

15

output:

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

result:

ok AC

Test #15:

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

input:

16

output:

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

result:

ok AC