結果
問題 | No.401 数字の渦巻き |
ユーザー |
![]() |
提出日時 | 2016-07-22 22:31:17 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,264 bytes |
コンパイル時間 | 786 ms |
コンパイル使用メモリ | 88,408 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-06 09:04:04 |
合計ジャッジ時間 | 1,762 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 30 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:66:18: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘ll’ {aka ‘long long int’} [-Wformat=] 66 | printf("%03d", d[y+1][x+1]); | ~~~^ ~~~~~~~~~~~ | | | | int ll {aka long long int} | %03lld
ソースコード
#include <algorithm>#include <cfloat>#include <climits>#include <cmath>#include <complex>#include <cstdio>#include <cstdlib>#include <cstring>#include <functional>#include <iostream>#include <map>#include <memory>#include <queue>#include <set>#include <sstream>#include <stack>#include <string>#include <utility>#include <vector>#include <list>using namespace std;typedef long long ll;#define sz size()#define pb push_back#define mp make_pair#define fi first#define se second#define along long(c) (c).begin(), (c).end()#define rep(i,a,b) for(ll i=(a);i<(b);++i)#define clr(a, b) memset((a), (b) ,sizeof(a))#define ctos(d) string(1,d)#define print(x) cout<<#x<<" = "<<x<<endl;#define MOD 1000000007ll d[55][55];int main() {ll n;cin >> n;clr(d, -1);rep(y, 0, n) {rep(x, 0, n) {d[y + 1][x + 1] = 0;}}int dy[4] = {0, 1, 0, -1};int dx[4] = {1, 0, -1, 0};int py = 1;int px = 1;int dd = 0;rep(i, 1, n * n+1) {d[py][px] = i;if (d[py + dy[dd]][px + dx[dd]] != 0) {dd++;dd %= 4;}py += dy[dd];px += dx[dd];}rep(y,0,n){rep(x,0,n){printf("%03d", d[y+1][x+1]);if(x!=n-1)cout << " ";}cout << endl;}return 0;}