CSES - Datatähti 2023 alku - Results
Submission details
Task:Ruudukko
Sender:snowflake
Submission time:2022-11-13 20:54:43 +0200
Language:C++ (C++17)
Status:COMPILE ERROR

Compiler report

input/code.cpp:6:19: error: declaration does not declare anything [-fpermissive]
    6 | typedef long long int;
      |                   ^~~

Code

#include <iostream>
#include <vector>
#include <tuple>
using namespace std;

typedef long long int;


const int dismo = 1000000007;

int n = 0;

int** multimatrix;
int** saved;
vector<tuple<int, int>>** occROW;	// tuple<index_x, index_y>


int A(int index_x, int index_y)
{
	int squareval = multimatrix[index_x][index_y];
	int svalmo = squareval - 1;
	if (squareval == 1)
		return 0;

	int save = saved[index_x][index_y];
	if (save != -1)
		return save;


	int count = 0;


	for (int i = 0; i < svalmo; ++i)
	{
		vector<tuple<int, int>> vex = occROW[index_y][i];

		int oursize = vex.size();

		count += oursize;

		for (int m = 0; m < oursize; ++m)
		{
			tuple<int, int> tup = vex[m];
			count += A(get<0>(tup), get<1>(tup));
		}

		count %= dismo;
	}

	for (int i = 0; i < n; ++i)
	{
		if (i == index_y) continue;
		int ne = multimatrix[index_x][i];
		if (ne == 1)
		{
			count++;
			continue;
		}
		if (ne >= squareval) continue;
		int coconut = saved[index_x][i];
		if (coconut == -1)
		{
			count = (count + A(index_x, i) + 1) % dismo;
		}
		else
		{
			count = (count + coconut + 1) % dismo;
		}

		count %= dismo;
	}

	saved[index_x][index_y] = count;
	return count;
}


int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);

	int countLIBERAL = 0;

	cin >> n;

	int sqrn = n * n;

	occROW = new vector<tuple<int, int>>* [n];
	for (int i = 0; i < n; ++i)
	{
		occROW[i] = new vector<tuple<int, int>>[sqrn];
		for (int iu = 0; iu < sqrn; ++iu)
		{
			occROW[i][iu] = vector<tuple<int, int>>();
		}
	}

	multimatrix = new int* [n];
	saved = new int* [n];
	for (int i = 0; i < n; ++i)
	{
		multimatrix[i] = new int[n];
		saved[i] = new int[n];

		for (int i7 = 0; i7 < n; ++i7)
		{
			saved[i][i7] = -1;

			int mycin = 0;
			cin >> mycin;
			multimatrix[i][i7] = mycin;

			occROW[i7][mycin - 1].push_back(make_tuple(i, i7));
		}
	}

	for (int lx = 0; lx < n; ++lx)
		for (int ny = 0; ny < n; ++ny)
		{
			countLIBERAL += A(lx, ny);
		}


	cout << (countLIBERAL + sqrn) % dismo;




	return 0;
}