QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#116690#6320. Parallel Processing (Hard)AFewSunsAC ✓1ms3804kbC++142.5kb2023-06-29 19:33:222023-06-29 19:33:24

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-06-29 19:33:24]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3804kb
  • [2023-06-29 19:33:22]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
namespace my_std{
	#define ll long long
	#define bl bool
	ll my_pow(ll a,ll b,ll mod){
		ll res=1;
		if(!b) return 1;
		while(b){
			if(b&1) res=(res*a)%mod;
			a=(a*a)%mod;
			b>>=1;
		}
		return res;
	}
	ll qpow(ll a,ll b){
		ll res=1;
		if(!b) return 1;
		while(b){
			if(b&1) res*=a;
			a*=a;
			b>>=1;
		}
		return res;
	}
	#define db double
	#define pf printf
	#define pc putchar
	#define fr(i,x,y) for(register ll i=(x);i<=(y);i++)
	#define pfr(i,x,y) for(register ll i=(x);i>=(y);i--)
	#define go(u) for(ll i=head[u];i;i=e[i].nxt)
	#define enter pc('\n')
	#define space pc(' ')
	#define fir first
	#define sec second
	#define MP make_pair
	#define il inline
	#define inf 8e18
	#define random(x) rand()*rand()%(x)
	#define inv(a,mod) my_pow((a),(mod-2),(mod))
	il ll read(){
		ll sum=0,f=1;
		char ch=0;
		while(!isdigit(ch)){
			if(ch=='-') f=-1;
			ch=getchar();
		}
		while(isdigit(ch)){
			sum=sum*10+(ch^48);
			ch=getchar();
		}
		return sum*f;
	}
	il void write(ll x){
		if(x<0){
			x=-x;
			pc('-');
		}
		if(x>9) write(x/10);
		pc(x%10+'0');
	}
	il void writeln(ll x){
		write(x);
		enter;
	}
	il void writesp(ll x){
		write(x);
		space;
	}
}
using namespace my_std;
vector<ll> ans;
ll n,a[1010],b[1010];
ll f7[22]={0,2,4,6,6,3,4,7,7,5,6,7,7};
ll f8[22]={0,2,4,6,8,3,4,7,8,5,6,7,8};
ll f9[22]={0,2,4,6,8,3,4,8,8,5,6,8,8,7,9,9,9};
ll f10[22]={0,2,4,6,8,3,4,8,10,5,6,8,8,7,9,10,10};
ll f11[22]={0,2,4,6,8,3,4,8,10,5,6,8,11,7,9,10,11};
void solve(ll x){
	if(x==7){
		fr(i,1,12) ans.push_back(f7[i]);
		return;
	}
	if(x==8){
		fr(i,1,12) ans.push_back(f8[i]);
		return;
	}
	if(x==9){
		fr(i,1,16) ans.push_back(f9[i]);
		return;
	}
	if(x==10){
		fr(i,1,16) ans.push_back(f10[i]);
		return;
	}
	if(x==11){
		fr(i,1,16) ans.push_back(f11[i]);
		return;
	}
	solve(x-5);
	ll tmp[5]={0,0,0,0,0};
	pfr(i,4,1){
		tmp[i]=ans.back();
		ans.pop_back();
	}
	fr(i,1,3) if(tmp[i]==tmp[4]) tmp[i]=x-3;
	ans.push_back(tmp[1]);
	ans.push_back(tmp[4]);
	ans.push_back(x-3);
	ans.push_back(x-1);
	ans.push_back(tmp[2]);
	ans.push_back(tmp[3]);
	ans.push_back(x-3);
	ans.push_back(x);
	ans.push_back(x-4);
	ans.push_back(x-2);
	ans.push_back(x-1);
	ans.push_back(x);
}
int main(){
	n=read();
	solve(n);
	fr(i,1,n) a[i]=i;
	writeln(ans.size()/4);
	fr(i,0,(ll)ans.size()/4-1){
		fr(j,1,n) b[j]=a[j];
		fr(j,0,3){
			pf("%lld %lld %lld\n",ans[i*4+j],b[ans[i*4+j]]-1,ans[i*4+j]);
			a[ans[i*4+j]]=b[b[ans[i*4+j]]-1];
		}
	}
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3632kb

input:

17

output:

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

result:

ok AC

Test #2:

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

input:

18

output:

7
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
8 4 8
10 9 10
12 11 12
6 4 6
7 4 7
10 8 10
13 12 13
9 8 9
13 10 13
15 14 15
17 16 17
11 10 11
12 10 12
15 13 15
18 17 18
14 13 14
16 15 16
17 15 17
18 15 18

result:

ok AC

Test #3:

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

input:

19

output:

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

result:

ok AC

Test #4:

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

input:

20

output:

8
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
8 4 8
7 6 7
10 8 10
12 11 12
14 13 14
9 8 9
12 10 12
12 10 12
15 14 15
11 10 11
15 12 15
17 16 17
19 18 19
13 12 13
14 12 14
17 15 17
20 19 20
16 15 16
18 17 18
19 17 19
20 17 20

result:

ok AC

Test #5:

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

input:

21

output:

8
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
11 8 11
13 12 13
15 14 15
9 8 9
10 8 10
13 11 13
16 15 16
12 11 12
16 13 16
18 17 18
20 19 20
14 13 14
15 13 15
18 16 18
21 20 21
17 16 17
19 18 19
20 18 20
21 18 21

result:

ok AC

Test #6:

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

input:

120

output:

48
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
8 4 8
7 6 7
10 8 10
12 11 12
14 13 14
9 8 9
12 10 12
12 10 12
15 14 15
11 10 11
15 12 15
17 16 17
19 18 19
13 12 13
14 12 14
17 15 17
20 19 20
16 15 16
20 17 20
22 21 22
24 23 24
18 17 18
19 17 19
22 20 22
25 24 25
21 20 21
25 22...

result:

ok AC

Test #7:

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

input:

421

output:

168
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
11 8 11
13 12 13
15 14 15
9 8 9
10 8 10
13 11 13
16 15 16
12 11 12
16 13 16
18 17 18
20 19 20
14 13 14
15 13 15
18 16 18
21 20 21
17 16 17
21 18 21
23 22 23
25 24 25
19 18 19
20 18 20
23 21 23
26 25 26
22 21 22
26...

result:

ok AC

Test #8:

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

input:

464

output:

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

result:

ok AC

Test #9:

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

input:

812

output:

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

result:

ok AC

Test #10:

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

input:

862

output:

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

result:

ok AC

Test #11:

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

input:

996

output:

398
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
11 8 11
13 12 13
15 14 15
9 8 9
10 8 10
13 11 13
16 15 16
12 11 12
16 13 16
18 17 18
20 19 20
14 13 14
15 13 15
18 16 18
21 20 21
17 16 17
21 18 21
23 22 23
25 24 25
19 18 19
20 18 20
23 21 23
26 25 26
22 21 22
26...

result:

ok AC

Test #12:

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

input:

997

output:

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

result:

ok AC

Test #13:

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

input:

998

output:

399
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
8 4 8
10 9 10
12 11 12
6 4 6
7 4 7
10 8 10
13 12 13
9 8 9
13 10 13
15 14 15
17 16 17
11 10 11
12 10 12
15 13 15
18 17 18
14 13 14
18 15 18
20 19 20
22 21 22
16 15 16
17 15 17
20 18 20
23 22 23
19 18 19
23 20 23
25 24 25
27 26 27
21 20 21
22 2...

result:

ok AC

Test #14:

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

input:

999

output:

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

result:

ok AC

Test #15:

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

input:

1000

output:

400
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
8 4 8
7 6 7
10 8 10
12 11 12
14 13 14
9 8 9
12 10 12
12 10 12
15 14 15
11 10 11
15 12 15
17 16 17
19 18 19
13 12 13
14 12 14
17 15 17
20 19 20
16 15 16
20 17 20
22 21 22
24 23 24
18 17 18
19 17 19
22 20 22
25 24 25
21 20 21
25 2...

result:

ok AC