QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#408283#5550. JOIRISAFewSuns30 1ms3864kbC++142.0kb2024-05-09 22:54:122024-05-09 22:54:14

Judging History

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

  • [2024-05-09 22:54:14]
  • 评测
  • 测评结果:30
  • 用时:1ms
  • 内存:3864kb
  • [2024-05-09 22:54:12]
  • 提交

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<pair<ll,ll> > ans;
ll n,k,a[55],b[55];
il void solve(ll l,ll r){
	ll maxx=0;
	fr(i,l,r) maxx=max(maxx,a[i]);
	fr(i,1,n){
		while((i<l||i>r)&&a[i]<=maxx){
			ans.push_back(MP(1,i));
			a[i]+=k;
		}
	}
	ans.push_back(MP(2,l));
	fr(i,l,r) a[i]++;
}
int main(){
	n=read();
	k=read();
	fr(i,1,n) a[i]=read();
	fr(i,1,n+1) b[i]=(a[i]%k-a[i-1]%k+k)%k;
	fr(i,1,n-k+1){
		ll tmp=(k-b[i])%k;
		fr(j,1,tmp) solve(i,i+k-1);
		b[i]=0;
		b[i+k]=(b[i+k]-tmp+k)%k;
	}
	fr(i,2,n){
		if(b[i]){
			write(-1);
			return 0;
		}
	}
	ll maxx=0;
	fr(i,1,n) maxx=max(maxx,a[i]);
	fr(i,1,n) fr(j,1,(maxx-a[i])/k) ans.push_back(MP(1,i));
	writeln(ans.size());
	fr(i,0,(ll)ans.size()-1) pf("%lld %lld\n",ans[i].fir,ans[i].sec);
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 15
Accepted

Test #1:

score: 15
Accepted
time: 1ms
memory: 3576kb

input:

34 2
2
5
41
47
8
27
42
17
43
47
47
12
49
33
41
18
4
16
15
28
9
13
25
44
20
40
25
16
2
20
0
41
6
16

output:

-1

result:

ok 

Test #2:

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

input:

26 2
32
42
0
0
20
22
4
19
13
37
22
30
50
17
23
1
11
7
22
3
26
25
45
32
38
38

output:

-1

result:

ok 

Test #3:

score: 15
Accepted
time: 1ms
memory: 3680kb

input:

32 2
3
42
8
32
34
44
2
4
19
40
49
47
25
6
46
7
40
22
38
6
32
45
4
35
16
29
47
6
1
22
0
14

output:

-1

result:

ok 

Test #4:

score: 15
Accepted
time: 1ms
memory: 3848kb

input:

28 2
9
21
26
30
0
46
33
7
36
29
28
0
33
21
29
37
15
44
33
14
14
34
32
4
49
23
48
19

output:

427
1 5
1 5
1 5
1 5
1 5
1 5
1 5
1 5
1 5
1 5
1 5
1 8
1 8
1 8
1 8
1 8
1 8
1 8
1 8
1 12
1 12
1 12
1 12
1 12
1 12
1 12
1 12
1 12
1 12
1 12
1 14
1 17
1 17
1 17
1 17
1 20
1 20
1 20
1 20
1 21
1 21
1 21
1 21
1 24
1 24
1 24
1 24
1 24
1 24
1 24
1 24
1 24
1 28
1 28
2 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1...

result:

ok 

Test #5:

score: 15
Accepted
time: 1ms
memory: 3640kb

input:

48 2
46
2
38
42
24
39
45
26
36
10
43
12
44
44
9
23
5
38
1
25
31
46
21
5
0
19
49
28
0
2
39
4
42
29
5
28
46
20
13
44
6
8
26
43
7
11
15
2

output:

-1

result:

ok 

Test #6:

score: 15
Accepted
time: 0ms
memory: 3768kb

input:

12 2
30
34
48
32
0
10
20
21
36
8
12
19

output:

153
1 1
1 1
1 1
1 1
1 2
1 2
1 4
1 4
1 4
1 5
1 5
1 5
1 5
1 5
1 5
1 5
1 5
1 5
1 5
1 5
1 5
1 5
1 5
1 5
1 5
1 5
1 5
1 5
1 6
1 6
1 6
1 6
1 6
1 6
1 6
1 6
1 6
1 6
1 6
1 6
1 6
1 6
1 7
1 7
1 7
1 7
1 7
1 7
1 7
1 7
1 7
1 10
1 10
1 10
1 10
1 10
1 10
1 10
1 10
1 10
1 10
1 10
1 10
1 10
1 10
1 10
1 11
1 11
1 11
1 ...

result:

ok 

Test #7:

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

input:

28 2
23
5
49
37
34
46
50
15
14
12
28
13
38
21
2
19
13
21
0
35
42
28
35
7
44
15
13
44

output:

-1

result:

ok 

Test #8:

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

input:

38 2
42
43
50
3
2
50
23
16
26
45
17
32
20
8
45
17
3
6
12
4
14
26
43
9
49
46
37
12
9
1
12
31
34
35
10
7
32
0

output:

-1

result:

ok 

Test #9:

score: 15
Accepted
time: 1ms
memory: 3788kb

input:

42 2
44
20
50
41
29
16
14
21
34
43
23
19
50
3
16
49
18
22
21
49
29
48
33
44
17
0
26
26
39
24
6
29
5
39
40
25
4
50
48
6
1
39

output:

932
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 6
1 6
1 6
1 6
1 6
1 6
1 6
1 6
1 6
1 6
1 6
1 6
1 6
1 7
1 7
1 7
1 7
1 7
1 7
1 7
1 7
1 7
1 7
1 7
1 7
1 7
1 7
1 8
1 8
1 8
1 8
1 8
1 8
1 8
1 8
1 8
1 8
1 8
1 9
1 9
1 9
1 9
1 11
1 11
1 11
1 11
1 11
1 11
1 11
1 11
1 11
1 11
1 12
1 12
1 12
1 12
1 12
1 12
1 12...

result:

ok 

Test #10:

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

input:

8 2
19
24
12
6
0
21
42
11

output:

-1

result:

ok 

Test #11:

score: 15
Accepted
time: 0ms
memory: 3540kb

input:

2 2
0
1

output:

-1

result:

ok 

Test #12:

score: 15
Accepted
time: 1ms
memory: 3836kb

input:

2 2
50
0

output:

25
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2

result:

ok 

Test #13:

score: 15
Accepted
time: 1ms
memory: 3496kb

input:

50 2
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1

output:

-1

result:

ok 

Test #14:

score: 15
Accepted
time: 1ms
memory: 3592kb

input:

50 2
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0

output:

-1

result:

ok 

Test #15:

score: 15
Accepted
time: 1ms
memory: 3760kb

input:

50 2
0
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50

output:

25
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1

result:

ok 

Test #16:

score: 15
Accepted
time: 0ms
memory: 3796kb

input:

50 2
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
0
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50
50

output:

25
1 27
1 27
1 27
1 27
1 27
1 27
1 27
1 27
1 27
1 27
1 27
1 27
1 27
1 27
1 27
1 27
1 27
1 27
1 27
1 27
1 27
1 27
1 27
1 27
1 27

result:

ok 

Subtask #2:

score: 0
Wrong Answer

Test #17:

score: 0
Wrong Answer
time: 0ms
memory: 3584kb

input:

3 2
38
27
0

output:

-1

result:

wrong answer 

Subtask #3:

score: 15
Accepted

Dependency #1:

100%
Accepted

Test #33:

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

input:

3 3
20
0
26

output:

-1

result:

ok 

Test #34:

score: 15
Accepted
time: 1ms
memory: 3720kb

input:

4 2
21
36
0
19

output:

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

result:

ok 

Test #35:

score: 15
Accepted
time: 0ms
memory: 3448kb

input:

10 5
2
27
17
0
4
26
7
50
41
3

output:

-1

result:

ok 

Test #36:

score: 15
Accepted
time: 0ms
memory: 3504kb

input:

24 6
27
20
23
19
30
40
49
35
19
27
7
45
37
17
0
11
36
2
32
28
43
39
23
16

output:

-1

result:

ok 

Test #37:

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

input:

39 13
34
40
36
9
46
24
34
0
14
44
3
42
7
43
43
12
24
18
31
48
36
2
34
33
48
47
11
16
18
39
3
38
11
41
42
8
15
23
36

output:

-1

result:

ok 

Test #38:

score: 15
Accepted
time: 0ms
memory: 3492kb

input:

42 7
9
19
27
32
23
49
20
19
26
28
24
21
27
44
29
40
3
47
29
5
46
24
21
45
9
1
2
23
50
24
37
0
18
6
27
27
18
34
20
30
27
11

output:

-1

result:

ok 

Test #39:

score: 15
Accepted
time: 0ms
memory: 3620kb

input:

46 23
36
40
6
34
18
0
16
32
4
18
13
47
4
45
27
30
16
21
26
11
21
34
35
28
36
28
24
8
20
36
1
12
29
49
21
15
30
41
33
32
44
46
6
11
10
15

output:

-1

result:

ok 

Test #40:

score: 15
Accepted
time: 1ms
memory: 3584kb

input:

47 47
18
21
16
42
0
7
5
11
14
15
45
41
2
17
32
40
16
33
24
32
10
10
49
34
44
12
33
14
34
47
40
22
39
48
11
23
32
44
44
48
45
22
37
26
49
5
18

output:

-1

result:

ok 

Test #41:

score: 15
Accepted
time: 0ms
memory: 3708kb

input:

49 7
50
9
16
17
5
47
18
0
6
45
28
10
30
34
6
0
27
1
11
39
2
6
1
39
33
6
5
2
12
11
41
16
11
38
39
12
6
6
39
34
0
48
15
49
30
14
50
8
27

output:

-1

result:

ok 

Test #42:

score: 15
Accepted
time: 0ms
memory: 3504kb

input:

50 5
45
27
44
21
35
4
39
0
47
6
46
11
47
39
47
42
25
18
15
20
18
16
34
0
43
46
1
42
18
20
41
38
45
40
37
44
11
3
39
28
21
47
2
31
30
13
18
16
30
8

output:

-1

result:

ok 

Test #43:

score: 15
Accepted
time: 1ms
memory: 3736kb

input:

48 4
1
0
1
2
1
0
1
2
1
0
1
2
1
0
1
2
1
0
1
2
1
0
1
2
1
0
1
2
1
0
1
2
1
0
1
2
1
0
1
2
1
0
1
2
1
0
1
2

output:

1428
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 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
2 1
2 1
1 6
1 10
1 14
1 18
1 22
1 26
1 30
1 34
1 38
1 42
1 46
2 1
1 1
1 7
1 9
1 ...

result:

ok 

Test #44:

score: 15
Accepted
time: 0ms
memory: 3784kb

input:

4 2
6
0
4
10

output:

10
1 1
1 1
1 2
1 2
1 2
1 2
1 2
1 3
1 3
1 3

result:

ok 

Test #45:

score: 15
Accepted
time: 1ms
memory: 3844kb

input:

10 5
27
25
46
22
24
19
21
0
24
22

output:

84
1 6
1 6
1 6
1 6
1 6
1 6
1 7
1 7
1 7
1 7
1 7
1 7
1 8
1 8
1 8
1 8
1 8
1 8
1 8
1 8
1 8
1 8
1 9
1 9
1 9
1 9
1 9
1 10
1 10
1 10
1 10
1 10
2 1
1 10
2 1
2 1
1 1
1 1
1 1
1 1
1 9
2 2
1 1
1 8
2 2
1 2
1 2
1 2
1 2
1 2
2 3
1 10
2 3
2 3
1 9
2 3
1 1
1 2
1 3
2 4
2 4
1 10
2 4
2 4
1 4
1 4
1 4
1 4
1 4
2 5
1 1
1 2
1...

result:

ok 

Test #46:

score: 15
Accepted
time: 0ms
memory: 3788kb

input:

24 6
3
2
4
4
4
3
4
2
4
4
2
2
3
11
2
2
6
7
5
0
5
5
3
3

output:

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

result:

ok 

Test #47:

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

input:

39 13
24
26
29
33
25
31
30
25
0
34
29
30
27
33
26
26
23
30
23
25
27
43
23
29
25
27
26
31
28
27
28
29
28
31
40
26
25
28
29

output:

853
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
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 36
1 37
1 38
1 39
2 1
2 1
1 1
1 1
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
2 2
2 2
2 2
1 17
1 19
1 23
2 2
2 2
...

result:

ok 

Test #48:

score: 15
Accepted
time: 1ms
memory: 3864kb

input:

42 7
8
9
0
5
10
8
8
9
11
6
11
13
8
10
8
12
8
10
5
9
6
5
5
12
8
6
6
11
9
4
12
10
6
8
8
10
8
11
5
9
10
6

output:

917
1 8
1 10
1 13
1 14
1 15
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 25
1 26
1 27
1 29
1 30
1 32
1 33
1 34
1 35
1 36
1 37
1 39
1 40
1 41
1 42
2 1
1 9
1 11
1 28
1 30
1 38
2 1
1 16
1 19
1 22
1 23
1 24
1 31
1 39
2 1
1 10
1 12
1 21
1 26
1 27
1 33
1 42
2 1
2 1
1 13
1 15
1 17
1 25
1 34
1 35
1 37
2 1
1 1
1 20
...

result:

ok 

Test #49:

score: 15
Accepted
time: 1ms
memory: 3708kb

input:

46 23
13
7
8
8
9
11
9
8
9
10
12
19
10
9
5
9
11
10
6
6
9
8
10
6
12
11
11
10
8
10
11
10
9
7
0
9
10
14
10
8
9
13
13
10
11
9

output:

579
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 40
1 41
1 42
1 43
1 44
1 45
1 46
2 1
2 1
2 1
2 1
1 35
2 1
2 1
2 1
2 1
2 1
2 1
1 1
2 2
1 34
2 2
1 29
1 40
2 2
1 33
1 36
1 41
1 46
2 2
1 28
1 30
1 32
1 37
1 39
1 44
2 2
1 26
1 27
1 31
1 45
2 2
1 2
2 3
1 42
1 43
2 3
1...

result:

ok 

Test #50:

score: 15
Accepted
time: 1ms
memory: 3544kb

input:

48 4
1
2
3
36
0
3
2
50
1
2
3
36
0
3
2
50
1
2
3
36
0
3
2
50
1
2
3
36
0
3
2
50
1
2
3
36
0
3
2
50
1
2
3
36
0
3
2
50

output:

-1

result:

ok 

Test #51:

score: 15
Accepted
time: 1ms
memory: 3856kb

input:

49 7
4
7
7
8
7
9
4
9
3
8
7
4
7
8
7
10
5
4
12
3
10
7
6
7
6
5
5
13
11
4
6
10
8
12
0
8
9
5
8
8
8
6
3
10
11
6
5
5
8

output:

1617
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 17
1 18
1 20
1 22
1 23
1 24
1 25
1 26
1 27
1 30
1 31
1 33
1 35
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 46
1 47
1 48
1 49
2 1
1 9
1 16
1 20
1 21
1 32
1 43
1 44
2 1
1 12
1 18
1 29
1 30
1 45
2 1
1 1
1 1
1 10
1 11
1 13
1 14
1 15
1 17
1 19
1 22
1 23
1 2...

result:

ok 

Test #52:

score: 15
Accepted
time: 0ms
memory: 3792kb

input:

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

output:

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

result:

ok 

Test #53:

score: 15
Accepted
time: 1ms
memory: 3680kb

input:

2 1
50
0

output:

50
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2

result:

ok 

Test #54:

score: 15
Accepted
time: 1ms
memory: 3704kb

input:

5 1
0
1
2
3
4

output:

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

result:

ok 

Subtask #4:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%