Submission

Status:

-----Txxxx

Subtask/Task Score:

0/100

Score: 0

User: Fifaxmb

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

Language: cpp

Time: 1.097 second

Submitted On: 2026-03-28 14:40:31

#include<bits/stdc++.h>
using namespace std;
#define Sigma_Fifa main
#define Fifa67king ios::sync_with_stdio(0);cin.tie(0);
using tiiii = tuple<int,int,int,int>;
int Sigma_Fifa(){
    Fifa67king;
    int n; cin >> n;
    int dx[] = {0, 1, 0, -1};
    int dy[] = {1, 0, -1, 0};
    vector<int> last(n);
    vector<vector<bool>> vis(n, vector<bool>(n, false));
    queue<tiiii> q; // x, y, d, num
    q.push({0, 0, 0, 1});

    while(!q.empty()){
        auto [x, y, d, num] = q.front(); q.pop();
        if(vis[x][y]) continue;
        vis[x][y] = true;
        if(x == n-1) last[y] = num;
        int xx = x + dx[d];
        int yy = y + dy[d];
        if(xx<0 || xx>=n || yy<0 || yy>=n || vis[xx][yy]){
            d = (d+1) % 4;
            xx = x + dx[d];
            yy = y + dy[d];
        }
        if(xx>=0 && xx<n && yy>=0 && yy < n) q.push({xx, yy, d, num+1});
    }
    int ans = 0;
    for(int j = 0; j < n; j++) ans += last[j] % 10;
    cout << ans;
}