Submission

Status:

PPPPxxxxxx

Subtask/Task Score:

40/100

Score: 40

User: kittipos

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

Language: cpp

Time: 0.033 second

Submitted On: 2026-03-04 23:58:02

#include <iostream>
#include <vector>

using namespace std;

vector<vector<int>> table;

int main() {
  int n;
  cin >> n;

  table.assign(n, vector<int>(n, -1));

  int count = 0;
  int x = 0;
  int y = 0;
  int status = 0;
  while (count < n * n) {
    count++;
    // status++;
    status %= 6;
    // cout << "status: " << status << ", count: " << count << ", x: " << x
    //      << ", y: " << y << endl;

    table[y][x] = count;
    if (status == 0) {
      x++;
      if (x >= n) {
        x--;
        count--;
        status++;
      }
    } else if (status == 1) {
      y++;
      status++;
    } else if (status == 2) {
      x--;
      if (x < 0 || table[y][x] != -1) {
        x++;
        count--;
        status++;
      }
    } else if (status == 3) {
      y++;
      if (y >= n) {
        y--;
        count--;
        status++;
      }
    } else if (status == 4) {
      x++;
      status++;
    } else if (status == 5) {
      y--;
      if (table[y][x] != -1) {
        count--;
        status++;
        y++;
      }
    }
  }

  int sum = 0;
  for (int i = 0; i < n; i++) {
    sum += table[n - 1][i] % 10;
  }
  cout << sum;
  return 0;
}