QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#102668#5260. The GameguduWA 2ms3604kbC++141.6kb2023-05-03 15:43:522023-05-03 15:43:53

Judging History

This is the latest submission verdict.

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-03 15:43:53]
  • Judged
  • Verdict: WA
  • Time: 2ms
  • Memory: 3604kb
  • [2023-05-03 15:43:52]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M (998244353)
#define N (300010)
int a[100],now[10],cnt[5],line[5][100];

int find1(int x){
	for (int i=1;i<=x;++i){
		for (int j=1;j<=4;++j) if (cnt[j]){
			if ((j<=2&&line[j][cnt[j]]-now[i]==10)||
				(j>2&&now[i]-line[j][cnt[j]]==10)){
				line[j][++cnt[j]]=now[i];
				return i;
			}
		}
	}
	return -1;
}

int find2(int x){
	int id1,id2,mi=100;
	for (int i=1;i<=x;++i){
		for (int j=1;j<=4;++j){
			if ((j<=2&&line[j][cnt[j]]<now[i])||
				(j>2&&now[i]<line[j][cnt[j]])){
				if (abs(now[i]-line[j][cnt[j]])<mi)
					id1=i,id2=j,mi=abs(now[i]-line[j][cnt[j]]);
			}
		}
	}
	if (mi==100) return -1;
	line[id2][++cnt[id2]]=now[id1];
	return id1;
} 

void Print(int x){
	for (int i=1;i<=4;++i){
		for (int j=0;j<=cnt[i];++j)
			printf("%d ",line[i][j]);
		cout<<endl; 
	}
	if (x<=91) for (int i=1;i<=(x%2==1?8:7);++i) printf("%d ",now[i]);
	else for (int i=1;i<=(98-x+1);++i) printf("%d ",now[i]);
	cout<<endl;
	if (x<=90) for (int i=x+8;i<=98;++i) printf("%d ",a[i]);
	cout<<endl;
}

int main(){
	for (int i=1;i<=98;++i) scanf("%d",&a[i]);
	line[1][0]=line[2][0]=1; line[3][0]=line[4][0]=100;
	for (int i=1;i<=8;++i) now[i]=a[i];
	for (int i=1;i<=90;++i){
		int x=i%2==1?8:7; 
		int id=find1(x);
		if (id==-1) id=find2(x);
		if (id==-1){Print(i); return 0;}
		for (int j=id;j<8;++j) now[j]=now[j+1];
		now[8]=a[8+i];
	}
	for (int i=8;i>=1;--i){
		int id=find1(i);
		if (id==-1) id=find2(i);
		if (id==-1){Print(98-i+1); return 0;}
		for (int j=id;j<i;++j) now[j]=now[j+1];
	} 
	Print(99);
	return 0;
}

詳細信息

Test #1:

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

input:

2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99

output:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 
1 
100 
100...

result:

ok 5 lines

Test #2:

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

input:

99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2

output:

1 2 
1 
100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 
100...

result:

ok 5 lines

Test #3:

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

input:

87 31 58 56 82 93 9 68 65 41 26 64 3 11 5 84 24 46 16 30 14 85 52 12 91 75 96 17 47 37 76 69 78 49 25 28 48 81 95 63 34 43 27 74 80 62 53 83 40 71 72 35 23 21 51 66 55 61 67 32 38 29 60 39 4 18 20 77 7 94 59 42 79 10 92 97 57 2 86 33 89 90 88 19 22 99 45 44 73 70 50 6 15 98 54 13 36 8

output:

1 9 11 16 24 14 17 26 28 30 31 34 62 74 78 80 81 71 72 83 95 96 97 99 
1 3 5 12 25 27 29 38 39 42 59 60 66 67 57 77 79 86 89 90 92 94 98 88 
100 93 87 82 68 65 64 58 56 46 41 37 47 43 53 51 61 55 45 44 33 22 20 19 15 13 10 8 6 
100 91 85 84 76 75 69 63 52 49 48 40 35 32 23 21 18 7 4 2 
73 70 50 54 3...

result:

ok 5 lines

Test #4:

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

input:

74 81 59 84 27 96 38 8 90 9 30 77 43 29 69 33 95 76 16 88 54 75 14 40 52 97 41 62 51 85 49 48 39 20 46 92 79 83 35 5 87 17 44 25 66 45 72 6 56 91 99 42 64 93 28 23 37 73 98 32 18 22 68 53 11 89 86 78 12 13 80 67 10 15 2 55 57 36 47 34 4 26 60 19 3 7 61 50 58 70 21 24 63 71 31 94 82 65

output:

1 8 9 14 16 20 66 56 72 79 83 87 91 92 93 97 98 99 89 
1 5 6 11 12 13 53 64 67 68 73 78 80 86 
100 96 90 84 81 77 74 69 59 43 38 33 30 29 27 25 17 15 10 4 2 
100 95 88 76 75 85 62 54 52 51 49 48 46 41 40 39 35 45 44 42 37 32 28 23 22 18 
55 57 36 47 34 26 60 19 
3 7 61 50 58 70 21 24 63 71 31 94 82 ...

result:

ok 6 lines

Test #5:

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

input:

76 93 21 29 17 95 69 59 67 11 20 85 56 6 62 90 84 92 50 60 37 44 61 14 82 8 32 53 70 83 75 97 24 22 86 64 73 25 5 9 39 54 57 46 40 2 96 41 10 34 16 78 23 87 38 58 55 47 18 3 51 77 48 65 63 68 19 91 72 42 80 31 89 26 4 79 81 27 12 88 7 52 35 43 28 33 98 36 13 99 74 30 49 94 71 15 66 45

output:

1 11 17 20 21 29 32 37 39 40 41 46 78 87 96 98 88 
1 6 8 14 22 24 25 34 38 42 63 65 68 72 77 79 80 81 89 91 94 99 
100 95 93 90 85 84 76 69 67 62 60 59 56 50 44 54 64 61 57 53 47 23 18 16 10 9 5 3 2 12 7 4 
100 97 92 86 83 82 75 73 70 58 55 51 48 43 35 33 31 28 27 26 36 30 19 15 13 
52 74 49 71 66 4...

result:

ok 5 lines

Test #6:

score: -100
Wrong Answer
time: 2ms
memory: 3512kb

input:

13 72 27 44 23 31 68 57 77 41 3 82 15 52 64 80 81 10 54 35 21 67 5 97 53 32 9 90 69 79 11 83 38 19 42 14 50 87 55 71 78 29 24 28 12 76 94 85 88 16 26 48 22 2 39 47 73 51 40 91 86 93 34 99 6 30 49 96 20 62 7 70 63 18 65 56 4 17 25 8 45 37 89 66 60 95 46 98 74 58 36 59 84 33 43 92 75 61

output:

1 13 23 27 31 41 44 52 57 64 68 72 77 80 81 82 83 87 88 94 99 
1 3 5 10 15 21 32 35 38 42 50 53 54 55 71 78 85 86 91 93 96 
100 97 90 79 69 67 29 28 24 19 14 12 11 9 2 
100 76 73 51 48 47 40 39 49 34 30 26 22 20 18 16 7 17 6 4 
62 70 63 65 56 25 8 
37 89 66 60 95 46 98 74 58 36 59 84 33 43 92 75 61 

result:

wrong answer 6th lines differ - expected: '45 37 89 66 60 95 46 98 74 58 36 59 84 33 43 92 75 61', found: '37 89 66 60 95 46 98 74 58 36 59 84 33 43 92 75 61 '