Submission #71664451
Source Code Expand
//#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include <stdlib.h>
#include<string>
#include<math.h>
#include<sstream>
#include<set>
#include<math.h>
#include <algorithm>
#include<map>
#include <numeric>
#include <sstream>
#include <iomanip>
#include<tuple>
#include <bitset>
#include <queue>
#include <iomanip>
#include <stack>
#include<time.h>
#include <unordered_set>
#include <random>
using namespace::std;
#define RANDMAX 100000
#define ll long long
#define lint long long int
#define ldouble long double
#define ALL(a) (a).begin(),(a).end()
using ve = vector<lint>;
vector<vector<int>> map2;
//
using Gra = vector<vector<lint>>;
using sve = vector<string>;
//
//cout << std::fixed << std::setprecision(15)<< ans;//�����_
//
//
//<stack>//�ォ��
// box.push()
// box.pop()
// box.top()
//
// <queue>������
// box.push()
// box.front()
// box.pop()
//
// <set>
// ite=g2.lower_bound(r) set�T��
// distance(ls.begin(), ite);�T��������̈���
// advance() �͋ɗ͎g��Ȃ����ƁI�I�@***************************************
// g2.count() set()���̌�
// lower_bound(a.begin(),a.end(),a[i])
// box.size()
//
// <vector>
// vector<int>
// lower_bound(a.begin(),a.end(),a[i])
// vector<vector<lint>> v(2, vector<lint>(3)) -> v.at(1).at(2);
// next_permutation(aaa.begin(), aaa.end()) �x�N�^�[�̑g�ݍ��킹
//
//<2���T���@�`�蓮�����`>
// int binary_search(int key) {
// int left = 0, right = (int)a.size() - 1; // �z�� a �̍��[�ƉE�[
// while (right >= left) {
// int mid = left + (right - left) / 2; // ��Ԃ̐^��
// if (a[mid] == key) return mid;
// else if (a[mid] > key) right = mid - 1;
// else if (a[mid] < key) left = mid + 1;
// }
// return -1;
// }
//
// <bit�S�T��>
//�@bitset<60> bs(n);
//
//�{��swap����Ƃ��͔��̔ԍ���ς���
/* par=time_check(nh, nm);
nh = par.first; nm = par.second;*/
pair<lint, lint> time_check(int h, int m) {
while (m >= 60) {
h += 1;
m -= 60;
}
while (m < 0) {
h -= 1;
m += 60;
}
return make_pair(h, m);
}
std::random_device seed_gen;
uint32_t get_rand() {
// ����������i�����ɃV�[�h���w��\�j
static std::mt19937 mt32(seed_gen());
// [0, (2^32)-1] �̈�l���z������
return mt32();
}
class ansd {
public:
int p;
int x;
int y;
};
class zahyo {
public:
int x;
int y;
};
int main() {
lint n,r,c,now=1;
cin >> n;
vector<vector<lint>> a(n, vector<lint>(n));
r = 0; c = (n - 1) / 2;
a[r][c] = 1;
for (lint i = 0; i < n * n - 1; i++) {
if (r == 0)r = n;
if (a[(r - 1) % n][(c + 1) % n] == 0) {
a[(r - 1) % n][(c + 1) % n] = ++now;
r = (r - 1) % n; c = (c + 1) % n;
}
else {
a[(r + 1) % n][c] = ++now;
r = (r + 1) % n;
}
}
for (lint i = 0; i < n ; i++) {
for (lint j = 0; j < n; j++) {
cout << a[i][j] << ' ';
}
cout << endl;
}
}
Submission Info
| Submission Time | |
|---|---|
| Task | B - Magic Square |
| User | tbbt95 |
| Language | C++23 (GCC 15.2.0) |
| Score | 200 |
| Code Size | 3414 Byte |
| Status | AC |
| Exec Time | 1 ms |
| Memory | 3692 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 200 / 200 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 00_sample_00.txt, 00_sample_01.txt |
| All | 00_sample_00.txt, 00_sample_01.txt, 01_test_00.txt, 01_test_01.txt, 01_test_02.txt, 01_test_03.txt, 01_test_04.txt, 01_test_05.txt, 01_test_06.txt, 01_test_07.txt, 01_test_08.txt, 01_test_09.txt, 01_test_10.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00_sample_00.txt | AC | 1 ms | 3564 KiB |
| 00_sample_01.txt | AC | 1 ms | 3628 KiB |
| 01_test_00.txt | AC | 1 ms | 3564 KiB |
| 01_test_01.txt | AC | 1 ms | 3408 KiB |
| 01_test_02.txt | AC | 1 ms | 3628 KiB |
| 01_test_03.txt | AC | 1 ms | 3564 KiB |
| 01_test_04.txt | AC | 1 ms | 3564 KiB |
| 01_test_05.txt | AC | 1 ms | 3692 KiB |
| 01_test_06.txt | AC | 1 ms | 3640 KiB |
| 01_test_07.txt | AC | 1 ms | 3692 KiB |
| 01_test_08.txt | AC | 1 ms | 3612 KiB |
| 01_test_09.txt | AC | 1 ms | 3692 KiB |
| 01_test_10.txt | AC | 1 ms | 3692 KiB |