提出 #45445826


ソースコード 拡げる

#include<bits/stdc++.h>
#define LL long long
#define DB double
#define MOD 1000000007
#define ls(x) (x << 1)
#define rs(x) (x << 1 | 1)
#define lowbit(x) ((-x) & x)
#define MP make_pair
#define VI vector<int>
#define VL vector<LL>
#define VII VI::iterator
#define VLI VL::iterator
#define all(x) x.begin(), x.end()
#define EB emplace_back
#define SI set<int>
#define SII SI::iterator
#define fi first
#define se second
using namespace std;
template<typename T> void chkmn(T &a, const T &b) { (a > b) && (a = b); }
template<typename T> void chkmx(T &a, const T &b) { (a < b) && (a = b); }
void Inc(int &a, const int &b) { ((a += b) >= MOD) && (a -= MOD); }
void Dec(int &a, const int &b) { ((a -= b) < 0) && (a += MOD); }
void Mul(int &a, const int &b) { a = 1LL * a * b % MOD; }
void Sqr(int &a) { a = 1LL * a * a % MOD; }
int inc(const int &a, const int &b) { return (a + b >= MOD) ? a + b - MOD : a + b; }
int dec(const int &a, const int &b) { return (a - b < 0) ? a - b + MOD : a - b; }
int mul(const int &a, const int &b) { return 1LL * a * b % MOD; }
int sqr(const int &a) { return 1LL * a * a % MOD; }
int qwqmi(int x, int k = MOD - 2)
{
	int res = 1;
	while(k)
	{
		if(k & 1) Mul(res, x);
		k >>= 1, Sqr(x);
	}
	return res;
}
const int N = 190;
int n, m;
char ch[N][N];
int s[N][N][N];
int f[20][N][N][N];
int main()
{
	scanf("%d %d", &n, &m);
	for(int i = 1; i <= n; ++i)
		scanf("%s", ch[i] + 1);
	for(int i = 1; i <= n; ++i)
		for(int l = 1; l <= m; ++l)
		{
			char c = ch[i][l];
			s[i][l][l] = 1;
			for(int r = l + 1; r <= m; ++r)
			{
				if(ch[i][r] != c) break;
				s[i][l][r] = 1;	
			}	
		}
	for(int i = 1; i <= n; ++i)
		for(int l = 1; l <= m; ++l)
			for(int r = l; r <= m; ++r)
			{
				for(int w = 0; w <= 16; ++w)
					f[w][i][l][r] = -1;
				if(s[i][l][r] == 0) continue;
				char c = ch[i][l];
				for(int x = i; x <= n; ++x)
				{
					if(s[x][l][r] == 0 || ch[x][l] != c)
						break;
					f[0][i][l][r] = x;
				}
			}
	
	for(int w = 1; w <= 16; ++w)
		for(int i = 1; i <= n; ++i)
			for(int l = 1; l <= m; ++l)
			{
				int p = l;
				for(int r = l; r <= m; ++r)
				{
					chkmx(f[w][i][l][r], f[w - 1][i][l][r]);
					if(f[w - 1][i][l][r] >= 1 && f[w - 1][i][l][r] < n)
						chkmx(f[w][i][l][r], f[w - 1][f[w - 1][i][l][r] + 1][l][r]);
					auto get = [&](int x) { return min(f[w - 1][i][l][x], f[w - 1][i][x + 1][r]); };
					while(p + 1 < r && get(p + 1) >= get(p)) ++p;
					if(l < r) chkmx(f[w][i][l][r], get(p));
				}
			}
	
	for(int w = 0; w <= 16; ++w)
		if(f[w][1][1][m] == n)
		{
			printf("%d", w);
			return 0;
		}
	return 0;
}

提出情報

提出日時
問題 D - Complexity
ユーザ Schucking_Sattin
言語 C++ 20 (gcc 12.2)
得点 1000
コード長 2673 Byte
結果 AC
実行時間 651 ms
メモリ 473532 KiB

コンパイルエラー

Main.cpp: In function ‘int main()’:
Main.cpp:47:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   47 |         scanf("%d %d", &n, &m);
      |         ~~~~~^~~~~~~~~~~~~~~~~
Main.cpp:49:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   49 |                 scanf("%s", ch[i] + 1);
      |                 ~~~~~^~~~~~~~~~~~~~~~~

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 1000 / 1000
結果
AC × 2
AC × 42
セット名 テストケース
Sample sample01.txt, sample02.txt
All sample01.txt, sample02.txt, in01.txt, in02.txt, in03.txt, in04.txt, in05.txt, in06.txt, in07.txt, in08.txt, in09.txt, in10.txt, in11.txt, in12.txt, in13.txt, in14.txt, in15.txt, in16.txt, in17.txt, in18.txt, in19.txt, in20.txt, in21.txt, in22.txt, in23.txt, in24.txt, in25.txt, in26.txt, in27.txt, in28.txt, in29.txt, in30.txt, in31.txt, in32.txt, in33.txt, in34.txt, in35.txt, in36.txt, in37.txt, in38.txt, sample01.txt, sample02.txt
ケース名 結果 実行時間 メモリ
in01.txt AC 389 ms 390016 KiB
in02.txt AC 458 ms 399004 KiB
in03.txt AC 394 ms 374656 KiB
in04.txt AC 455 ms 407608 KiB
in05.txt AC 361 ms 350524 KiB
in06.txt AC 438 ms 403916 KiB
in07.txt AC 556 ms 473428 KiB
in08.txt AC 549 ms 473312 KiB
in09.txt AC 650 ms 473276 KiB
in10.txt AC 1 ms 3760 KiB
in11.txt AC 630 ms 473484 KiB
in12.txt AC 603 ms 473340 KiB
in13.txt AC 574 ms 473412 KiB
in14.txt AC 572 ms 473412 KiB
in15.txt AC 569 ms 473448 KiB
in16.txt AC 560 ms 473484 KiB
in17.txt AC 297 ms 321704 KiB
in18.txt AC 263 ms 290744 KiB
in19.txt AC 253 ms 298492 KiB
in20.txt AC 237 ms 282392 KiB
in21.txt AC 457 ms 473300 KiB
in22.txt AC 651 ms 473336 KiB
in23.txt AC 437 ms 473312 KiB
in24.txt AC 451 ms 473324 KiB
in25.txt AC 353 ms 379408 KiB
in26.txt AC 472 ms 473484 KiB
in27.txt AC 392 ms 408828 KiB
in28.txt AC 432 ms 444052 KiB
in29.txt AC 445 ms 473368 KiB
in30.txt AC 432 ms 473484 KiB
in31.txt AC 433 ms 473520 KiB
in32.txt AC 442 ms 473308 KiB
in33.txt AC 436 ms 473480 KiB
in34.txt AC 438 ms 473412 KiB
in35.txt AC 454 ms 473372 KiB
in36.txt AC 454 ms 473532 KiB
in37.txt AC 542 ms 473372 KiB
in38.txt AC 539 ms 473420 KiB
sample01.txt AC 1 ms 4016 KiB
sample02.txt AC 1 ms 4796 KiB