Submission #3566875


Source Code Expand

#include <iostream>
#include <cassert>
#include <vector>
#include <random>
using namespace std;
typedef pair<int,int> P;
int N = 30,A[31][31],D[900] = {0};
int dx[4] = {-1,1,0,0},dy[4] = {0,0,-1,1},visited[31][31] = {{0}};
vector<P> ans,route;
/*mt19937 mt{random_device{}()};
uniform_int_distribution<int> rd(0,3);
*/
void print(){
	for(int i=1;i<=N;i++){
		for(int j=1;j<=N;j++){
			cout << A[i][j] << (j!=N? " ":"\n");
		}
	}
}

bool in(int x,int y){
	return 1<=x && x<=N && 1<=y && y<=N;
}

vector<P> make_route(){
	vector<P> res;
	for(int i=1;i<=N;i++){
		if(i%2==1){
			for(int j=1;j<=N;j++) res.push_back({i,j});
		}else{
			for(int j=N;j>=1;j--) res.push_back({i,j});
		}
	}
	return res;
}

void init(){
	for(int i=1;i<=N;i++){
		for(int j=1;j<=N;j++) visited[i][j] = 0;
	}
}


int main(){
	int x,y,ma = 0;
	for(int i=1;i<=N;i++){
		for(int j=1;j<=N;j++){
			cin >> A[i][j];
		}
	}
	route = make_route();
	for(int i=0;i<N*N;i++){
		if(i!=0) D[i] = max(0,A[route[i].first][route[i].second]-A[route[i-1].first][route[i-1].second]+1);
		else D[i] = A[route[i].first][route[i].second];
	}
//	cerr << route.size() << endl;
	for(int i=N*N-1;i>=0;i--){
		int c = 0;
		x = route[i].first; y = route[i].second;
		while(c<D[i]){
			ans.push_back({x,y});
			A[x][y]--; c++;
			for(int k=i+1;k<=N*N-1;k++){
				if(A[route[k-1].first][route[k-1].second]!=0 && A[route[k-1].first][route[k-1].second]==A[route[k].first][route[k].second]){
					ans.push_back({route[k].first,route[k].second});
					A[route[k].first][route[k].second]--;
				}
			}
		}
	}
	for(int i=0;i<ans.size();i++){
		cout << ans[i].first << " " << ans[i].second << endl;
	}
}

Submission Info

Submission Time
Task A - 高橋君の山崩しゲーム
User idsigma
Language C++14 (GCC 5.4.1)
Score 842712
Code Size 1712 Byte
Status AC
Exec Time 91 ms
Memory 1028 KB

Judge Result

Set Name test_01 test_02 test_03 test_04 test_05 test_06 test_07 test_08 test_09 test_10
Score / Max Score 84676 / 100000 84099 / 100000 84342 / 100000 84012 / 100000 84240 / 100000 84064 / 100000 85027 / 100000 83919 / 100000 84073 / 100000 84260 / 100000
Status
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
AC × 1
Set Name Test Cases
test_01 subtask_01_01.txt
test_02 subtask_01_02.txt
test_03 subtask_01_03.txt
test_04 subtask_01_04.txt
test_05 subtask_01_05.txt
test_06 subtask_01_06.txt
test_07 subtask_01_07.txt
test_08 subtask_01_08.txt
test_09 subtask_01_09.txt
test_10 subtask_01_10.txt
Case Name Status Exec Time Memory
subtask_01_01.txt AC 87 ms 1028 KB
subtask_01_02.txt AC 91 ms 1028 KB
subtask_01_03.txt AC 87 ms 1028 KB
subtask_01_04.txt AC 91 ms 1028 KB
subtask_01_05.txt AC 88 ms 1028 KB
subtask_01_06.txt AC 87 ms 1028 KB
subtask_01_07.txt AC 90 ms 1028 KB
subtask_01_08.txt AC 87 ms 1028 KB
subtask_01_09.txt AC 91 ms 1028 KB
subtask_01_10.txt AC 91 ms 1028 KB