結果

問題 No.1169 Row and Column and Diagonal
ユーザー m1025o1184tm1025o1184t
提出日時 2020-08-14 23:15:07
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,091 bytes
コンパイル時間 2,108 ms
コンパイル使用メモリ 178,860 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-18 23:06:16
合計ジャッジ時間 4,298 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
template<class T> inline istream& operator >> (istream & c, vector<T> & A) {rep(i, A.size()) c >> A[i];return c;}
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<vector<int>> a(n, vector<int>(n));
	rep(i, n) {
		a[i][i] = i + 1;
		vector<int> tmp;
		map<int, int> mp;
		rep(j, n) mp[a[i][j]] = 1;
		rep(j, n) if (!mp[j + 1]) tmp.push_back(j + 1);
		if(tmp.size() >= 2) rotate(tmp.begin(), tmp.begin() + tmp.size() - 1, tmp.end());
		for (int j = i + 1, pos = 0; j < n; ++j, pos++) a[i][j] = tmp[pos];
		for (int j = i + 1, pos = 0; j < n; ++j, pos++) a[j][i] = tmp[pos];
	}
	rep(i, n)rep(j, n) cout << a[i][j] << (j == n - 1 ? "\n" : " ");
	return 0;
}
0