QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#250556 | #5176. 多控制反转 | Crysfly | 100 ✓ | 1ms | 3464kb | C++17 | 1.7kb | 2023-11-13 12:47:07 | 2023-11-13 12:47:07 |
Judging History
answer
// what is matter? never mind.
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,sse4,popcnt,abm,mmx,avx,avx2")
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
#define ll long long
#define ull unsigned long long
//#define int long long
using namespace std;
inline int read()
{
char c=getchar();int x=0;bool f=0;
for(;!isdigit(c);c=getchar())f^=!(c^45);
for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
if(f)x=-x;return x;
}
#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;
#define maxn 300005
#define inf 0x3f3f3f3f
int n;
vector<array<int,4>>out;
void add(int a,int b,int c,int d){out.pb({a,b,c,d});}
void solve(vi a,vi b,int o){
int n=a.size();
if(n==0){
add(1,b[0],-1,-1);
return;
}
if(n==1){
add(2,a[0],b[0],-1);
return;
}
if(n==2){
add(3,a[0],a[1],b[0]);
return;
}
add(3,a[0],b[1],b[0]);
vi aa=a,bb=b;
aa.erase(aa.begin());
bb.erase(bb.begin());
solve(aa,bb,1);
add(3,a[0],b[1],b[0]);
if(o==0) solve(aa,bb,1);
}
signed main()
{
n=read(),read(),read(),read();
if(n==0)puts("1"),puts("1 0"),exit(0);
if(n==1)puts("1"),puts("2 0 1"),exit(0);
For(_,0,1){
vi a,b;
For(i,0,n/2-1)a.pb(i); a.pb(n+1);
b.pb(n); For(i,n/2,n-1)b.pb(i);
// cout<<"solve "<<a.size()<<"\n";
solve(a,b,0);
a.clear(),b.clear();
For(i,n/2,n-1)a.pb(i);
b.pb(n+1); For(i,0,n/2-1)b.pb(i);
// cout<<"solve "<<a.size()<<"\n";
solve(a,b,0);
}
cout<<out.size()<<"\n";
for(auto [a,b,c,d]:out)cout<<a<<" "<<b<<" "<<c<<" "<<d<<"\n";
return 0;
}
/*
*/
詳細信息
Subtask #1:
score: 15
Accepted
Test #1:
score: 15
Accepted
time: 1ms
memory: 3464kb
input:
0 2 1 1
output:
1 1 0
result:
ok OK.
Test #2:
score: 0
Accepted
time: 0ms
memory: 3396kb
input:
13 28 105 1
output:
80 3 0 6 13 3 1 7 6 3 2 8 7 3 3 9 8 3 4 10 9 3 5 14 10 3 4 10 9 3 3 9 8 3 2 8 7 3 1 7 6 3 0 6 13 3 1 7 6 3 2 8 7 3 3 9 8 3 4 10 9 3 5 14 10 3 4 10 9 3 3 9 8 3 2 8 7 3 1 7 6 3 6 0 14 3 7 1 0 3 8 2 1 3 9 3 2 3 10 4 3 3 11 12 4 3 10 4 3 3 9 3 2 3 8 2 1 3 7 1 0 3 6 0 14 3 7 1 0 3 8 2 1 3 9 3 2 3 10 4 3 ...
result:
ok OK.
Test #3:
score: 0
Accepted
time: 0ms
memory: 3440kb
input:
5 12 41 1
output:
16 3 0 2 5 3 1 6 2 3 0 2 5 3 1 6 2 3 2 0 6 3 3 4 0 3 2 0 6 3 3 4 0 3 0 2 5 3 1 6 2 3 0 2 5 3 1 6 2 3 2 0 6 3 3 4 0 3 2 0 6 3 3 4 0
result:
ok OK.
Test #4:
score: 0
Accepted
time: 1ms
memory: 3376kb
input:
20 42 161 1
output:
136 3 0 10 20 3 1 11 10 3 2 12 11 3 3 13 12 3 4 14 13 3 5 15 14 3 6 16 15 3 7 17 16 3 8 18 17 3 9 21 18 3 8 18 17 3 7 17 16 3 6 16 15 3 5 15 14 3 4 14 13 3 3 13 12 3 2 12 11 3 1 11 10 3 0 10 20 3 1 11 10 3 2 12 11 3 3 13 12 3 4 14 13 3 5 15 14 3 6 16 15 3 7 17 16 3 8 18 17 3 9 21 18 3 8 18 17 3 7 17...
result:
ok OK.
Subtask #2:
score: 10
Accepted
Dependency #1:
100%
Accepted
Test #5:
score: 10
Accepted
time: 1ms
memory: 3444kb
input:
48 98 385 2
output:
360 3 0 24 48 3 1 25 24 3 2 26 25 3 3 27 26 3 4 28 27 3 5 29 28 3 6 30 29 3 7 31 30 3 8 32 31 3 9 33 32 3 10 34 33 3 11 35 34 3 12 36 35 3 13 37 36 3 14 38 37 3 15 39 38 3 16 40 39 3 17 41 40 3 18 42 41 3 19 43 42 3 20 44 43 3 21 45 44 3 22 46 45 3 23 49 46 3 22 46 45 3 21 45 44 3 20 44 43 3 19 43 4...
result:
ok OK.
Test #6:
score: 0
Accepted
time: 0ms
memory: 3376kb
input:
41 84 329 2
output:
304 3 0 20 41 3 1 21 20 3 2 22 21 3 3 23 22 3 4 24 23 3 5 25 24 3 6 26 25 3 7 27 26 3 8 28 27 3 9 29 28 3 10 30 29 3 11 31 30 3 12 32 31 3 13 33 32 3 14 34 33 3 15 35 34 3 16 36 35 3 17 37 36 3 18 38 37 3 19 42 38 3 18 38 37 3 17 37 36 3 16 36 35 3 15 35 34 3 14 34 33 3 13 33 32 3 12 32 31 3 11 31 3...
result:
ok OK.
Test #7:
score: 0
Accepted
time: 0ms
memory: 3372kb
input:
50 102 401 2
output:
376 3 0 25 50 3 1 26 25 3 2 27 26 3 3 28 27 3 4 29 28 3 5 30 29 3 6 31 30 3 7 32 31 3 8 33 32 3 9 34 33 3 10 35 34 3 11 36 35 3 12 37 36 3 13 38 37 3 14 39 38 3 15 40 39 3 16 41 40 3 17 42 41 3 18 43 42 3 19 44 43 3 20 45 44 3 21 46 45 3 22 47 46 3 23 48 47 3 24 51 48 3 23 48 47 3 22 47 46 3 21 46 4...
result:
ok OK.
Subtask #3:
score: 10
Accepted
Dependency #2:
100%
Accepted
Test #8:
score: 10
Accepted
time: 1ms
memory: 3404kb
input:
0 2 1 3
output:
1 1 0
result:
ok OK.
Test #9:
score: 0
Accepted
time: 1ms
memory: 3380kb
input:
19 40 153 3
output:
128 3 0 9 19 3 1 10 9 3 2 11 10 3 3 12 11 3 4 13 12 3 5 14 13 3 6 15 14 3 7 16 15 3 8 20 16 3 7 16 15 3 6 15 14 3 5 14 13 3 4 13 12 3 3 12 11 3 2 11 10 3 1 10 9 3 0 9 19 3 1 10 9 3 2 11 10 3 3 12 11 3 4 13 12 3 5 14 13 3 6 15 14 3 7 16 15 3 8 20 16 3 7 16 15 3 6 15 14 3 5 14 13 3 4 13 12 3 3 12 11 3...
result:
ok OK.
Test #10:
score: 0
Accepted
time: 1ms
memory: 3364kb
input:
47 96 377 3
output:
352 3 0 23 47 3 1 24 23 3 2 25 24 3 3 26 25 3 4 27 26 3 5 28 27 3 6 29 28 3 7 30 29 3 8 31 30 3 9 32 31 3 10 33 32 3 11 34 33 3 12 35 34 3 13 36 35 3 14 37 36 3 15 38 37 3 16 39 38 3 17 40 39 3 18 41 40 3 19 42 41 3 20 43 42 3 21 44 43 3 22 48 44 3 21 44 43 3 20 43 42 3 19 42 41 3 18 41 40 3 17 40 3...
result:
ok OK.
Test #11:
score: 0
Accepted
time: 1ms
memory: 3364kb
input:
25 52 201 3
output:
176 3 0 12 25 3 1 13 12 3 2 14 13 3 3 15 14 3 4 16 15 3 5 17 16 3 6 18 17 3 7 19 18 3 8 20 19 3 9 21 20 3 10 22 21 3 11 26 22 3 10 22 21 3 9 21 20 3 8 20 19 3 7 19 18 3 6 18 17 3 5 17 16 3 4 16 15 3 3 15 14 3 2 14 13 3 1 13 12 3 0 12 25 3 1 13 12 3 2 14 13 3 3 15 14 3 4 16 15 3 5 17 16 3 6 18 17 3 7...
result:
ok OK.
Test #12:
score: 0
Accepted
time: 1ms
memory: 3396kb
input:
50 102 401 3
output:
376 3 0 25 50 3 1 26 25 3 2 27 26 3 3 28 27 3 4 29 28 3 5 30 29 3 6 31 30 3 7 32 31 3 8 33 32 3 9 34 33 3 10 35 34 3 11 36 35 3 12 37 36 3 13 38 37 3 14 39 38 3 15 40 39 3 16 41 40 3 17 42 41 3 18 43 42 3 19 44 43 3 20 45 44 3 21 46 45 3 22 47 46 3 23 48 47 3 24 51 48 3 23 48 47 3 22 47 46 3 21 46 4...
result:
ok OK.
Subtask #4:
score: 10
Accepted
Test #13:
score: 10
Accepted
time: 1ms
memory: 3348kb
input:
0 2 1 4
output:
1 1 0
result:
ok OK.
Test #14:
score: 0
Accepted
time: 1ms
memory: 3416kb
input:
18 20 325 4
output:
120 3 0 9 18 3 1 10 9 3 2 11 10 3 3 12 11 3 4 13 12 3 5 14 13 3 6 15 14 3 7 16 15 3 8 19 16 3 7 16 15 3 6 15 14 3 5 14 13 3 4 13 12 3 3 12 11 3 2 11 10 3 1 10 9 3 0 9 18 3 1 10 9 3 2 11 10 3 3 12 11 3 4 13 12 3 5 14 13 3 6 15 14 3 7 16 15 3 8 19 16 3 7 16 15 3 6 15 14 3 5 14 13 3 4 13 12 3 3 12 11 3...
result:
ok OK.
Test #15:
score: 0
Accepted
time: 1ms
memory: 3324kb
input:
14 16 197 4
output:
88 3 0 7 14 3 1 8 7 3 2 9 8 3 3 10 9 3 4 11 10 3 5 12 11 3 6 15 12 3 5 12 11 3 4 11 10 3 3 10 9 3 2 9 8 3 1 8 7 3 0 7 14 3 1 8 7 3 2 9 8 3 3 10 9 3 4 11 10 3 5 12 11 3 6 15 12 3 5 12 11 3 4 11 10 3 3 10 9 3 2 9 8 3 1 8 7 3 7 0 15 3 8 1 0 3 9 2 1 3 10 3 2 3 11 4 3 3 12 13 4 3 11 4 3 3 10 3 2 3 9 2 1 ...
result:
ok OK.
Test #16:
score: 0
Accepted
time: 1ms
memory: 3364kb
input:
20 22 401 4
output:
136 3 0 10 20 3 1 11 10 3 2 12 11 3 3 13 12 3 4 14 13 3 5 15 14 3 6 16 15 3 7 17 16 3 8 18 17 3 9 21 18 3 8 18 17 3 7 17 16 3 6 16 15 3 5 15 14 3 4 14 13 3 3 13 12 3 2 12 11 3 1 11 10 3 0 10 20 3 1 11 10 3 2 12 11 3 3 13 12 3 4 14 13 3 5 15 14 3 6 16 15 3 7 17 16 3 8 18 17 3 9 21 18 3 8 18 17 3 7 17...
result:
ok OK.
Subtask #5:
score: 20
Accepted
Dependency #4:
100%
Accepted
Test #17:
score: 20
Accepted
time: 1ms
memory: 3444kb
input:
18 20 325 5
output:
120 3 0 9 18 3 1 10 9 3 2 11 10 3 3 12 11 3 4 13 12 3 5 14 13 3 6 15 14 3 7 16 15 3 8 19 16 3 7 16 15 3 6 15 14 3 5 14 13 3 4 13 12 3 3 12 11 3 2 11 10 3 1 10 9 3 0 9 18 3 1 10 9 3 2 11 10 3 3 12 11 3 4 13 12 3 5 14 13 3 6 15 14 3 7 16 15 3 8 19 16 3 7 16 15 3 6 15 14 3 5 14 13 3 4 13 12 3 3 12 11 3...
result:
ok OK.
Test #18:
score: 0
Accepted
time: 1ms
memory: 3392kb
input:
17 19 290 5
output:
112 3 0 8 17 3 1 9 8 3 2 10 9 3 3 11 10 3 4 12 11 3 5 13 12 3 6 14 13 3 7 18 14 3 6 14 13 3 5 13 12 3 4 12 11 3 3 11 10 3 2 10 9 3 1 9 8 3 0 8 17 3 1 9 8 3 2 10 9 3 3 11 10 3 4 12 11 3 5 13 12 3 6 14 13 3 7 18 14 3 6 14 13 3 5 13 12 3 4 12 11 3 3 11 10 3 2 10 9 3 1 9 8 3 8 0 18 3 9 1 0 3 10 2 1 3 11...
result:
ok OK.
Test #19:
score: 0
Accepted
time: 1ms
memory: 3436kb
input:
20 22 401 5
output:
136 3 0 10 20 3 1 11 10 3 2 12 11 3 3 13 12 3 4 14 13 3 5 15 14 3 6 16 15 3 7 17 16 3 8 18 17 3 9 21 18 3 8 18 17 3 7 17 16 3 6 16 15 3 5 15 14 3 4 14 13 3 3 13 12 3 2 12 11 3 1 11 10 3 0 10 20 3 1 11 10 3 2 12 11 3 3 13 12 3 4 14 13 3 5 15 14 3 6 16 15 3 7 17 16 3 8 18 17 3 9 21 18 3 8 18 17 3 7 17...
result:
ok OK.
Subtask #6:
score: 10
Accepted
Test #20:
score: 10
Accepted
time: 1ms
memory: 3364kb
input:
14 16 393 6
output:
88 3 0 7 14 3 1 8 7 3 2 9 8 3 3 10 9 3 4 11 10 3 5 12 11 3 6 15 12 3 5 12 11 3 4 11 10 3 3 10 9 3 2 9 8 3 1 8 7 3 0 7 14 3 1 8 7 3 2 9 8 3 3 10 9 3 4 11 10 3 5 12 11 3 6 15 12 3 5 12 11 3 4 11 10 3 3 10 9 3 2 9 8 3 1 8 7 3 7 0 15 3 8 1 0 3 9 2 1 3 10 3 2 3 11 4 3 3 12 13 4 3 11 4 3 3 10 3 2 3 9 2 1 ...
result:
ok OK.
Test #21:
score: 0
Accepted
time: 0ms
memory: 3428kb
input:
39 41 1093 6
output:
288 3 0 19 39 3 1 20 19 3 2 21 20 3 3 22 21 3 4 23 22 3 5 24 23 3 6 25 24 3 7 26 25 3 8 27 26 3 9 28 27 3 10 29 28 3 11 30 29 3 12 31 30 3 13 32 31 3 14 33 32 3 15 34 33 3 16 35 34 3 17 36 35 3 18 40 36 3 17 36 35 3 16 35 34 3 15 34 33 3 14 33 32 3 13 32 31 3 12 31 30 3 11 30 29 3 10 29 28 3 9 28 27...
result:
ok OK.
Test #22:
score: 0
Accepted
time: 1ms
memory: 3392kb
input:
0 2 1 6
output:
1 1 0
result:
ok OK.
Test #23:
score: 0
Accepted
time: 1ms
memory: 3432kb
input:
50 52 1401 6
output:
376 3 0 25 50 3 1 26 25 3 2 27 26 3 3 28 27 3 4 29 28 3 5 30 29 3 6 31 30 3 7 32 31 3 8 33 32 3 9 34 33 3 10 35 34 3 11 36 35 3 12 37 36 3 13 38 37 3 14 39 38 3 15 40 39 3 16 41 40 3 17 42 41 3 18 43 42 3 19 44 43 3 20 45 44 3 21 46 45 3 22 47 46 3 23 48 47 3 24 51 48 3 23 48 47 3 22 47 46 3 21 46 4...
result:
ok OK.
Subtask #7:
score: 10
Accepted
Dependency #2:
100%
Accepted
Dependency #4:
100%
Accepted
Test #24:
score: 10
Accepted
time: 1ms
memory: 3456kb
input:
93 95 745 7
output:
720 3 0 46 93 3 1 47 46 3 2 48 47 3 3 49 48 3 4 50 49 3 5 51 50 3 6 52 51 3 7 53 52 3 8 54 53 3 9 55 54 3 10 56 55 3 11 57 56 3 12 58 57 3 13 59 58 3 14 60 59 3 15 61 60 3 16 62 61 3 17 63 62 3 18 64 63 3 19 65 64 3 20 66 65 3 21 67 66 3 22 68 67 3 23 69 68 3 24 70 69 3 25 71 70 3 26 72 71 3 27 73 7...
result:
ok OK.
Test #25:
score: 0
Accepted
time: 1ms
memory: 3432kb
input:
82 84 657 7
output:
632 3 0 41 82 3 1 42 41 3 2 43 42 3 3 44 43 3 4 45 44 3 5 46 45 3 6 47 46 3 7 48 47 3 8 49 48 3 9 50 49 3 10 51 50 3 11 52 51 3 12 53 52 3 13 54 53 3 14 55 54 3 15 56 55 3 16 57 56 3 17 58 57 3 18 59 58 3 19 60 59 3 20 61 60 3 21 62 61 3 22 63 62 3 23 64 63 3 24 65 64 3 25 66 65 3 26 67 66 3 27 68 6...
result:
ok OK.
Test #26:
score: 0
Accepted
time: 1ms
memory: 3460kb
input:
100 102 801 7
output:
776 3 0 50 100 3 1 51 50 3 2 52 51 3 3 53 52 3 4 54 53 3 5 55 54 3 6 56 55 3 7 57 56 3 8 58 57 3 9 59 58 3 10 60 59 3 11 61 60 3 12 62 61 3 13 63 62 3 14 64 63 3 15 65 64 3 16 66 65 3 17 67 66 3 18 68 67 3 19 69 68 3 20 70 69 3 21 71 70 3 22 72 71 3 23 73 72 3 24 74 73 3 25 75 74 3 26 76 75 3 27 77 ...
result:
ok OK.
Subtask #8:
score: 15
Accepted
Dependency #3:
100%
Accepted
Dependency #5:
100%
Accepted
Dependency #6:
100%
Accepted
Dependency #7:
100%
Accepted
Test #27:
score: 15
Accepted
time: 1ms
memory: 3392kb
input:
94 96 753 8
output:
728 3 0 47 94 3 1 48 47 3 2 49 48 3 3 50 49 3 4 51 50 3 5 52 51 3 6 53 52 3 7 54 53 3 8 55 54 3 9 56 55 3 10 57 56 3 11 58 57 3 12 59 58 3 13 60 59 3 14 61 60 3 15 62 61 3 16 63 62 3 17 64 63 3 18 65 64 3 19 66 65 3 20 67 66 3 21 68 67 3 22 69 68 3 23 70 69 3 24 71 70 3 25 72 71 3 26 73 72 3 27 74 7...
result:
ok OK.
Test #28:
score: 0
Accepted
time: 1ms
memory: 3352kb
input:
70 72 561 8
output:
536 3 0 35 70 3 1 36 35 3 2 37 36 3 3 38 37 3 4 39 38 3 5 40 39 3 6 41 40 3 7 42 41 3 8 43 42 3 9 44 43 3 10 45 44 3 11 46 45 3 12 47 46 3 13 48 47 3 14 49 48 3 15 50 49 3 16 51 50 3 17 52 51 3 18 53 52 3 19 54 53 3 20 55 54 3 21 56 55 3 22 57 56 3 23 58 57 3 24 59 58 3 25 60 59 3 26 61 60 3 27 62 6...
result:
ok OK.
Test #29:
score: 0
Accepted
time: 0ms
memory: 3464kb
input:
100 102 801 8
output:
776 3 0 50 100 3 1 51 50 3 2 52 51 3 3 53 52 3 4 54 53 3 5 55 54 3 6 56 55 3 7 57 56 3 8 58 57 3 9 59 58 3 10 60 59 3 11 61 60 3 12 62 61 3 13 63 62 3 14 64 63 3 15 65 64 3 16 66 65 3 17 67 66 3 18 68 67 3 19 69 68 3 20 70 69 3 21 71 70 3 22 72 71 3 23 73 72 3 24 74 73 3 25 75 74 3 26 76 75 3 27 77 ...
result:
ok OK.
Extra Test:
score: 0
Extra Test Passed