Submission
Status:
PPPPxxxxxx
Subtask/Task Score:
40/100
Score: 40
User: s0m30n3
Problemset: โชว์ของโลมา
Language: cpp
Time: 0.029 second
Submitted On: 2026-02-02 22:53:15
#include<iostream>
#include<vector>
using ll = long long;
using namespace std;
vector<vector<ll>> table;
int n;
void write(int y, int x, int sum){
while(x<n){
table[y][x] = sum;
sum++;
x++;
}
y++;
x--;
if(y>=n || x>=n || x < 0 || y < 0) return;
while(table[y][x] == -1 && x >= 0){
table[y][x] = sum;
sum++;
x--;
}
x++;
y++;
if(y>=n || x>=n || x < 0 || y < 0) return;
while (y<n){
table[y][x] = sum;
sum++;
y++;
}
x++;
y--;
if(y>=n || x>=n || x < 0 || y < 0) return;
while(table[y][x] ==-1 && y>=0){
table[y][x] = sum;
sum++;
y--;
}
y++;
x++;
if(y>=n || x>=n || x < 0 || y < 0) return;
write(y,x,sum);
}
int main(){
cin >> n;
table.resize(n, vector<ll>(n,-1));
write(0,0,1);
ll answer=0;
for(int i=0;i<n;i++){
answer+=table[n-1][i] % 10;
}
cout << answer;
}