QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#855550#9439. Aim Highucup-team134AC ✓19ms3816kbC++141.5kb2025-01-12 23:46:402025-01-12 23:46:42

Judging History

This is the latest submission verdict.

  • [2025-01-12 23:46:42]
  • Judged
  • Verdict: AC
  • Time: 19ms
  • Memory: 3816kb
  • [2025-01-12 23:46:40]
  • Submitted

answer

#include <bits/stdc++.h>

#define ll long long
#define pb push_back
#define f first
#define s second
#define sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ld long double

using namespace std;

mt19937 rng(0);

vector<pair<pair<int,int>,pair<int,int>>> ans[7];
int main()
{
	for(int n=1;n<=4;n++){
		int cn=0;
		while(1){
			cn++;
			map<int,int> want;
			want[0]=1;
			vector<pair<pair<int,int>,pair<int,int>>> my;
			bool done=0;
			for(int y=n;y>-100;y--){
				if(y<=0){
					map<int,int> w2;
					for(auto p:want)if(p.s>1)w2[p.f]=p.s-1;
					want=w2;
				}
				if(sz(want)==0){
					done=1;
					break;
				}
				bool bad=0;
				for(auto p:want){
					if(p.s>2){
						bad=1;
					}
				}
				if(bad)break;
				map<int,int> w2;
				for(auto p:want){
					for(int i=0;i<p.s;i++){
						if(rng()%2){
							w2[p.f-1]++;
							my.pb({{p.f-1,y-1},{p.f,y-1}});
						}
						else{
							w2[p.f+1]++;
							my.pb({{p.f+1,y-1},{p.f,y-1}});
						}
						w2[p.f]++;
					}
				}
				want=w2;
			}
			if(done){
				reverse(all(my));
				ans[n]=my;
				break;
			}
		}
	}
	int t;
	cin >> t;
	while(t--){
		int n;
		cin >> n;
		if(sz(ans[n])==0){
			printf("-1\n");
		}
		else{
			printf("%i\n",sz(ans[n]));
			for(auto p:ans[n]){
				printf("%i %i %i %i %i %i\n",p.f.f,p.f.s,p.s.f,p.s.s,p.s.f,p.s.s+1);
			}
		}
	}
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 14ms
memory: 3816kb

input:

1
1

output:

1
1 0 0 0 0 1

result:

ok Output is valid. OK

Test #2:

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

input:

6
1
2
3
4
5
6

output:

1
1 0 0 0 0 1
3
1 0 0 0 0 1
-2 0 -1 0 -1 1
-1 1 0 1 0 2
32
-2 -8 -1 -8 -1 -7
-1 -7 0 -7 0 -6
-2 -7 -1 -7 -1 -6
1 -6 0 -6 0 -5
-2 -6 -1 -6 -1 -5
0 -6 -1 -6 -1 -5
-1 -5 0 -5 0 -4
-1 -5 0 -5 0 -4
-2 -5 -1 -5 -1 -4
0 -4 1 -4 1 -3
-1 -4 0 -4 0 -3
0 -4 -1 -4 -1 -3
-3 -4 -2 -4 -2 -3
1 -3 0 -3 0 -2
1 -3 0 -...

result:

ok Output is valid. OK

Extra Test:

score: 0
Extra Test Passed