Submission

Status:

PPPPPP----

Subtask/Task Score:

60/100

Score: 60

User: Nay-O

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

Language: cpp

Time: 0.800 second

Submitted On: 2026-03-15 22:08:22

#include<bits/stdc++.h>
using namespace std;
using pii = array<int,3>;

int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	
	int n; cin>> n;
	
	
	queue<pii> q;
	q.push({0,0,0}); // 0 right 1 left 2 down 3 up
	int c = 0;
	int ans = 0;
	int x = n;
	while(c<n*n){
		int a = q.front()[0], b = q.front()[1], d = q.front()[2];
		q.pop();
		for(int i= 0; i < x; i++){
			c++;
			if(a == n-1){
				ans += c%10;
			}
			a+=dy[d];
			b+=dx[d];
		}
		a-=dy[d];
		b-=dx[d];
		if(d==0||d==1){
			a++;
			if(d==1){
				x-=2;
			}
		}
		else{
			b++;
		}
		q.push({a,b,(d+1)%4});
	}
	
	
	cout << ans;
	
	return 0;
}