結果
| 問題 |
No.1169 Row and Column and Diagonal
|
| コンテスト | |
| ユーザー |
noritake
|
| 提出日時 | 2020-08-14 21:53:30 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 29 ms / 2,000 ms |
| コード長 | 1,035 bytes |
| コンパイル時間 | 1,582 ms |
| コンパイル使用メモリ | 171,500 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-10 15:04:28 |
| 合計ジャッジ時間 | 2,765 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 13 |
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:35:45: warning: 'target_column' may be used uninitialized [-Wmaybe-uninitialized]
35 | swap(G[i][x], G[i][target_column]);
| ^
main.cpp:26:13: note: 'target_column' was declared here
26 | int target_column;
| ^~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<bool> vb;
typedef vector<char> vc;
#define INF __INT32_MAX__
#define LINF __LONG_LONG_MAX__
int main() {
int N; cin >> N;
vector<vi> G(N, vi(N));
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
G[i][(j + i) % N] = j;
}
}
for (int x = 1; x < N; x++) {
// xが2の時、Gのうち2行目の値が2の列を見つける
int target_column;
for (int column = x; column < N; column++) {
if (G[x][column] == x) {
target_column = column;
break;
}
}
for (int i = 0; i < N; i++) {
swap(G[i][x], G[i][target_column]);
}
}
rep(i, N) {
rep(j, N) {
cout << (G[i][j] + 1);
if (j != N - 1) cout << " ";
}
cout << endl;
}
}
noritake