답안 #594186

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
594186 2022-07-12T08:00:09 Z 장태환(#8433) 영역 (JOI16_ho_t4) C++17
0 / 100
0 ms 212 KB
#include <bits/stdc++.h>
using namespace std;
vector<vector<int>>x;
vector<vector<vector<int>>>val;
vector<vector<vector<int>>>psum;
signed main()
{
	int N, M;
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> N >> M;
	int sw = 0;
	int i, j;
	for (i = 0; i < N; i++)
	{
		vector<int>y;
		for (j = 0; j < M; j++)
		{
			int a;
			cin >> a;
			y.push_back(a);
		}
		x.push_back(y);
	}
	if (N > M)
	{
		vector<vector<int>>t;
		int i, j;
		for (i = 0; i < M; i++)
		{
			vector<int>y;
			for (j = 0; j < N; j++)
			{
				y.push_back(x[j][i]);
			}
			t.push_back(y);
		}
		x = t;
		swap(N, M);
	}
	for (i = 0; i < N; i++)
	{
		vector<vector<int>>te;
		for (j = 0; j < M; j++)
		{
			vector<int>t;
			int k;
			for (k = 0; k < 16; k++)
			{
				vector<int>t3;
				if ((k & 1)&&i)
				{
					t3.push_back(x[i - 1][j]);
				}
				if ((k & 2) && j)
				{
					t3.push_back(x[i][j-1]);
				}
				if ((k & 4) && i!=N-1)
				{
					t3.push_back(x[i+1][j]);
				}
				if ((k & 8) && j != M - 1)
				{
					t3.push_back(x[i][j+1]);
				}
				sort(t3.begin(), t3.end());
				int l;
				int ll = 0;
				int u = 0;
				for (l = 0; l < t3.size(); l++)
				{
					if (t3[l] < x[i][j])
						ll = t3[l];
					else
					{
						u = 1;
						break;
					}
				}
				if (!u)
				{
					t.push_back((20060820) - ll);
				}
				else
				{
					t.push_back(x[i][j] - ll);
				}
			}
			te.push_back(t);
		}
		val.push_back(te);
		psum.push_back(te);
	}
	for (i = 0; i < N; i++)
	{
		for (j = 0; j < M; j++)
		{
			int k;
			for (k = 0; k < 16; k++)
			{
				if(i)
					psum[i][j][k] += psum[i - 1][j][k];
			}
		}
	}
	int ans = N*M;
	for (i = 0; i < N; i++)
	{
		for (j = i + 1; j < N; j++)
		{
			int k;
			for (k = 0; k < M; k++)
			{
				int v = val[j][k][9] + val[i][k][12];
				v += psum[j - 1][k][13]-psum[i][k][13];
				int l;
				for (l = k + 1; l < M; l++)
				{
					if (v + val[j][l][3] + val[i][l][6] + psum[j - 1][l][7] - psum[i][l][7]==(20060820))
					{
						ans++;
					}
					v += val[i][l][14]+val[j][l][11];
					v += -psum[i][l][15] + psum[j-1][l][15];
				}
			}
		}
	}
	for (i = 0; i < N; i++)
	{
		int k;
		for (k = 0; k < M; k++)
		{
			int v = val[i][k][8];
			int l;
			for (l = k + 1; l < M; l++)
			{
				if (v + val[i][l][2] == (20060820))
				{
					ans++;
				}
				v += val[i][l][10];
			}
		}
	}
	for (i = 0; i < M; i++)
	{
		int k;
		for (k = 0; k < N; k++)
		{
			int v = val[k][i][4];
			int l;
			for (l = k + 1; l < N; l++)
			{
				if (v + val[l][i][1] == (20060820))
				{
					ans++;
				}
				v += val[l][i][5];
			}
		}
	}
	cout << ans;
}

Compilation message

2016_ho_t4.cpp: In function 'int main()':
2016_ho_t4.cpp:71:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   71 |     for (l = 0; l < t3.size(); l++)
      |                 ~~^~~~~~~~~~~
2016_ho_t4.cpp:12:6: warning: unused variable 'sw' [-Wunused-variable]
   12 |  int sw = 0;
      |      ^~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -