Submission
Status:
----TTTTTT
Subtask/Task Score:
0/100
Score: 0
User: Fifaxmb
Problemset: โชว์ของโลมา
Language: cpp
Time: 1.097 second
Submitted On: 2026-03-28 15:29:58
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using tiii = tuple<int,int,int>;
#define Fifa67king ios::sync_with_stdio(0);cin.tie(0);
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
int main(){
Fifa67king;
int n; cin >> n;
queue<tiii> q;
q.push({0,0,0});
int k = 0,ans = 0,ss = n;
while(ss > 0){
auto [yy,xx,d] = q.front(); q.pop();
for(int i = 0; i < ss; i++){
k ++;
k %= 10;
if(yy == n-1) ans += k;
if(i != ss-1){
yy += dy[d];
xx += dx[d];
cout << k <<' ';
}
}
if(d == 0) yy++;
else if(d == 1){
yy++;
ss -= 2;
cout << '\n';
}
else xx ++;
d = (d+1)%4;
q.push({yy,xx,d});
}
cout << ans;
}