結果

問題 No.401 数字の渦巻き
ユーザー kotamanegi
提出日時 2016-07-22 22:46:03
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 2,288 bytes
コンパイル時間 726 ms
コンパイル使用メモリ 85,524 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-06 09:08:34
合計ジャッジ時間 1,657 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include<map>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <iomanip>
using namespace std;
#define MAX_MOD 1000000007
#define REP(i,n) for(int i = 0;i < n;++i)
int hoge[100][100] = {};
int main() {
int n;
cin >> n;
pair<int, int> now_here = make_pair(1,1);
hoge[1][1] = 1;
for (int i = 0;i < n;++i) {
hoge[0][i+1] = 99999;
hoge[i+1][0] = 99999;
hoge[i+1][n+1] = 99999;
hoge[n+1][i+1] = 99999;
}
int going = 0;
while (true) {
if (going == 0) {
if (hoge[now_here.first + 1][now_here.second] == 0) {
hoge[now_here.first + 1][now_here.second] = hoge[now_here.first][now_here.second] + 1;
now_here.first++;
}
else {
if (hoge[now_here.first][now_here.second+1] == 0) {
going = 1;
}
else goto endout;
}
}else if (going == 1) {
if (hoge[now_here.first][now_here.second + 1] == 0) {
hoge[now_here.first][now_here.second + 1] = hoge[now_here.first][now_here.second] + 1;
now_here.second++;
}
else {
if (hoge[now_here.first - 1][now_here.second] == 0) {
going = 2;
}
else goto endout;
}
}else if (going == 2) {
if (hoge[now_here.first - 1][now_here.second] == 0) {
hoge[now_here.first - 1][now_here.second] = hoge[now_here.first][now_here.second] + 1;
now_here.first--;
}
else {
if (hoge[now_here.first][now_here.second - 1] == 0) {
going = 3;
}
else goto endout;
}
} else if (going == 3) {
if (hoge[now_here.first][now_here.second - 1] == 0) {
hoge[now_here.first][now_here.second - 1] = hoge[now_here.first][now_here.second] + 1;
now_here.second--;
}
else {
if (hoge[now_here.first + 1][now_here.second] == 0) {
going = 0;
}
else goto endout;
}
}
}
endout:;
for (int i = 1;i <= n;++i) {
for (int q = 1;q <= n;++q) {
if (hoge[q][i] < 100) {
cout << "0";
}
if (hoge[q][i] < 10) {
cout << "0";
}
cout << hoge[q][i] << " ";
}
cout << endl;
}
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0