Submission
Status:
-P-P-P----
Subtask/Task Score:
30/100
Score: 30
User: Nay-O
Problemset: โชว์ของโลมา
Language: cpp
Time: 0.004 second
Submitted On: 2026-03-15 22:23:42
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
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(x>0){
int a = q.front()[0], b = q.front()[1], d = q.front()[2];
q.pop();
if(d==3){
ans += c+1;
}
c+=x;
c%=10;
if(d==2){
ans +=c;
}
a+=dy[d]*(x-1);
b+=dx[d]*(x-1);
if(d==0||d==1){
a++;
if(d==1){
x-=2;
}
}
else{
b++;
}
q.push({a,b,(d+1)%4});
}
ans += (n*n)%10;
if(n%2==0){
ans+=(n*n-1)%10;
}
cout << ans;
return 0;
}