Submission #49084333
Source Code Expand
/*
* __----~~~~~~~~~~~------___
* . . ~~//====...... __--~ ~~
* -. \_|// |||\\ ~~~~~~::::... /~
* ___-==_ _-~o~ \/ ||| \\ _/~~-
* __---~~~.==~||\=_ -_--~/_-~|- |\\ \\ _/~
* _-~~ .=~ | \\-_ '-~7 /- / || \ /
* .~ .~ | \\ -_ / /- / || \ /
* / ____ / | \\ ~-_/ /|- _/ .|| \ /
* |~~ ~~|--~~~~--_ \ ~==-/ | \~--===~~ .\
* ' ~-| /| |-~\~~ __--~~
* |-~~-_/ | | ~\_ _-~ /\
* / \ \__ \/~ \__
* _--~ _/ | .-~~____--~-/ ~~==.
* ((->/~ '.|||' -_| ~~-/ , . _||
* -_ ~\ ~~---l__i__i__i--~~_/
* _-~-__ ~) \--______________--~~
* //.-~~~-~_--~- |-------~~~~~~~~
* //.-~~~--\
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*
* 神兽保佑 永无BUG
*/
/*-------------Console begins here--------------*/
#define fastIO //
//#define fileIO //
#ifndef CONTEST_DURING //
//#define Test_case //
//#define Use_int_as_long_long //
//#define atcoder //
/*-------------Console ends here--------------*/
#include<bits/stdc++.h>
#ifdef atcoder
#ifdef ONLINE_JUDGE
#include <atcoder/all>
#endif
#endif
using namespace std;
#define IMIN INT_MIN
#define IMAX INT_MAX
#define UIMIN 0
#define UIMAX UINT_MAX
#define LLMIN LONG_LONG_MIN
#define LLMAX LONG_LONG_MAX
#define ULLMIN 0
#define ULLMAX ULLONG_MAX
#define MOD 998244353
#define MOD1 ((int)1e9+7)
//Types
#define str string
#define ll signed long long
#define ull unsigned long long
#define uint unsigned int
#ifdef Use_int_as_long_long
#define int long long
#endif
//Containers
#define arr(tttttttttt,nnnn,s_________) array<tttttttttt,s_________>nnnn
#define mset multiset
#define uset unordered_set
#define umset unordered_multiset
#define mmap multimap
#define umap unordered_map
#define ummap unordered_multimap
#define pii pair<int,int>
//Members
#define sz size
#define be begin
#define en end
#define fi first
#define se second
#define all(v) v.begin(),v.end()
//Functions
#define rem remove
#define era erase
#define ins insert
#define ssort stable_sort
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define pb push_back
#define m_p make_pair
#define rev reverse
#define empl emplace
#define empt empty
#define lb lower_bound
#define ub upper_bound
#define er equal_range
#define Sort(n) sort(all(n),cmp)
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define PER(i,b,e) for(int i=(b);i>=(e);--i)
#define foreach(i,n)for(auto &i:n)
#define over(x) {cout<<x<<'\n';return;}
int qpow(int A,int B,int m=MOD,int Res=1){
ll a=A%m,b=B,res=Res;
while(b>0){
res=(b&1)?(res*a%m):(res),a=a*a%m,b>>=1;
}
return res;
}
struct dsu{
#define SIZE 500000
vector<int>pa;
void init(){
pa.resize(SIZE+1);
for(int i=0;i<=SIZE;i++)pa[i]=i;
}
int find(int x){
assert(x>=0);assert(x<(int)pa.size());
return pa[x]==x?x:pa[x]=find(pa[x]);
}
bool same(int x,int y){
assert(x>=0);assert(x<(int)pa.size());
assert(y>=0);assert(y<(int)pa.size());
return find(x)==find(y);
}
void uni(int x,int y){
assert(x>=0);assert(x<(int)pa.size());
assert(y>=0);assert(y<(int)pa.size());
pa[find(x)]=find(y);
}
dsu(){init();}
#undef SIZE
};
template<typename T>T sqr(T x){return x*x;}
template<typename T>
struct Point{
T x,y;
Point(T x,T y):x(x),y(y){}
bool same(Point lhs){
return lhs.x==x&&lhs.y==y;
}
bool operator <(Point lhs)const{
return x<lhs.x||x==lhs.x&&y<=lhs.y;//Can be changed
}
bool operator ==(Point lhs)const{
return x==lhs.x&&y==lhs.y;
}
};
template<typename T>
Point<T>make_Point(T x,T y){
Point<T>ret;
ret.x=x,ret.y=y;
return ret;
}
inline string YN(bool x,bool up=0){return up?(x?"YES":"NO"):(x?"Yes":"No");}
inline bool OK(int x,int y,int n,int m=INT_MIN+1145144,bool index_1=0){
if(m==INT_MIN+1145144)m=n;
return (index_1?x>0&&x<=n&&y>0&&y<=m:x>=0&&x<n&&y>=0&&y<m);
}
template<typename T>
inline void chmax(T &x,T y){
if(x<y)x=y;
}
template<typename T>
inline void chmin(T &x,T y){
if(y<x)x=y;
}
template<typename T>
inline T Manh_Dist(Point<T>x,Point<T>y){
return (y.x<x.x?x.x-y.x:y.x-x.x)+(y.y<x.y?x.y-y.y:y.y-x.y);
}
template<typename T>
inline T Eucl_Dist(Point<T>x,Point<T>y){
return sqrt(sqr(abs(x.x-y.x))+sqr(abs(x.y-y.y)));
}
string revstr(string s){reverse(s.begin(),s.end());return s;}
bool is_digit(char Member__){return Member__>='0'&&Member__<='9';}
template<typename T>
inline bool cmp(T x,T y){
return x<y;
}
#endif
/*---------Code begins here---------*/
void init(){
}
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int a[50][50];
void solve(){
int n;
cin>>n;
int x=0,y=0,face=0,cnt=0;
while(cnt<n*n){
cnt++;
a[x][y]=cnt;
int nx=x+dx[face],ny=y+dy[face];
if(!OK(nx,ny,n)||a[nx][ny]){
face=(face+1)%4;
nx=x+dx[face],ny=y+dy[face];
}
x=nx,y=ny;
}
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
if(a[i][j]==n*n)cout<<'T';
else cout<<a[i][j];
cout<<" \n"[j==n-1];
}
}
}
/*---------Code ends here---------*/
signed main(){
#ifdef fastIO
ios::sync_with_stdio(0);cin.tie(0);
#endif
#ifdef fileIO
freopen(".in","r",stdin);
freopen(".out","w",stdout);
#endif
init();
#ifdef Test_case
unsigned long long t;
cin>>t;
while(t--)
#endif
solve();
return 0;
}
Submission Info
| Submission Time |
|
| Task |
D - Loong and Takahashi |
| User |
Kevin_pbw |
| Language |
C++ 20 (gcc 12.2) |
| Score |
350 |
| Code Size |
6359 Byte |
| Status |
AC |
| Exec Time |
1 ms |
| Memory |
3628 KiB |
Judge Result
| Set Name |
Sample |
All |
| Score / Max Score |
0 / 0 |
350 / 350 |
| Status |
|
|
| Set Name |
Test Cases |
| Sample |
sample_01.txt |
| All |
random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, sample_01.txt |
| Case Name |
Status |
Exec Time |
Memory |
| random_01.txt |
AC |
1 ms |
3404 KiB |
| random_02.txt |
AC |
1 ms |
3536 KiB |
| random_03.txt |
AC |
1 ms |
3428 KiB |
| random_04.txt |
AC |
1 ms |
3620 KiB |
| random_05.txt |
AC |
1 ms |
3536 KiB |
| random_06.txt |
AC |
1 ms |
3428 KiB |
| random_07.txt |
AC |
1 ms |
3540 KiB |
| random_08.txt |
AC |
1 ms |
3620 KiB |
| random_09.txt |
AC |
1 ms |
3628 KiB |
| random_10.txt |
AC |
1 ms |
3604 KiB |
| random_11.txt |
AC |
1 ms |
3436 KiB |
| random_12.txt |
AC |
1 ms |
3604 KiB |
| random_13.txt |
AC |
1 ms |
3536 KiB |
| random_14.txt |
AC |
1 ms |
3536 KiB |
| random_15.txt |
AC |
1 ms |
3496 KiB |
| random_16.txt |
AC |
1 ms |
3536 KiB |
| random_17.txt |
AC |
1 ms |
3624 KiB |
| random_18.txt |
AC |
1 ms |
3468 KiB |
| random_19.txt |
AC |
1 ms |
3532 KiB |
| random_20.txt |
AC |
1 ms |
3540 KiB |
| random_21.txt |
AC |
1 ms |
3544 KiB |
| sample_01.txt |
AC |
1 ms |
3592 KiB |