Submission #9486103
Source Code Expand
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back
#define print(x) cout<<(x)<<endl
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), n)
#define ub(v,n) upper_bound(v.begin(), v.end(), n)
//#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int,int>P;
const int MOD = 1e9 + 7; const int MAX = 200020;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 2e18;
int dx[4] = { 0,0,-1,1 }, dy[4] = { 1,-1,0,0 };
int A[30][30];
vector<int>X, Y;
void solve() {
const int N = 30;
priority_queue<pair<int, P>>que;
REP(i, N) {
REP(j, N) {
cin >> A[i][j];
que.push({ A[i][j],{i,j} });
}
}
while (!que.empty()) {
pair<int, P>p = que.top();
que.pop();
int c = p.first, x = p.second.first, y = p.second.second;
if (A[x][y] != c)continue;
A[x][y]--;
X.push_back(x), Y.push_back(y);
if (A[x][y] > 0)que.push({ A[x][y],{x,y} });
bool ok = true;
while (ok) {
ok = false;
REP(k, 4) {
int nx = x + dx[k], ny = y + dy[k];
if (nx < 0 || nx >= N || ny < 0 || ny >= N)continue;
if (A[nx][ny] == 0)continue;
if (A[nx][ny] == A[x][y]) {
ok = true;
x = nx, y = ny;
A[x][y]--;
X.push_back(x), Y.push_back(y);
if (A[x][y] > 0)que.push({ A[x][y],{ x,y } });
break;
}
}
}
}
int M = X.size();
REP(i, M) {
pe(X[i] + 1); print(Y[i] + 1);
}
}
signed main() {
cin.tie(0);
ios::sync_with_stdio(false);
//int q;cin>>q;
//while(q--)
solve();
}
Submission Info
Submission Time |
|
Task |
A - 高橋君の山崩しゲーム |
User |
Mojumbo |
Language |
C++14 (GCC 5.4.1) |
Score |
803215 |
Code Size |
2818 Byte |
Status |
AC |
Exec Time |
90 ms |
Memory |
1180 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 |
80358 / 100000 |
80179 / 100000 |
80729 / 100000 |
79442 / 100000 |
80561 / 100000 |
80394 / 100000 |
80715 / 100000 |
80304 / 100000 |
80540 / 100000 |
79993 / 100000 |
Status |
|
|
|
|
|
|
|
|
|
|
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 |
86 ms |
1052 KB |
subtask_01_02.txt |
AC |
88 ms |
1052 KB |
subtask_01_03.txt |
AC |
83 ms |
1008 KB |
subtask_01_04.txt |
AC |
90 ms |
1180 KB |
subtask_01_05.txt |
AC |
85 ms |
1008 KB |
subtask_01_06.txt |
AC |
83 ms |
1052 KB |
subtask_01_07.txt |
AC |
87 ms |
1052 KB |
subtask_01_08.txt |
AC |
82 ms |
1052 KB |
subtask_01_09.txt |
AC |
85 ms |
1052 KB |
subtask_01_10.txt |
AC |
84 ms |
1052 KB |