Submission

Status:

PPPPPPTTTT

Subtask/Task Score:

60/100

Score: 60

User: Fifaxmb

Problemset: โชว์ของโลมา

Language: cpp

Time: 1.096 second

Submitted On: 2026-03-28 15:31:20

#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];
            }
        }
        if(d == 0) yy++;
        else if(d == 1){
            yy++;
            ss -= 2;
        }
        else xx ++;
        d = (d+1)%4;
        q.push({yy,xx,d});
    }
    cout << ans;
}