QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#505798#4642. 炮兵阵地RainPPRCompile Error//C++201.1kb2024-08-05 11:37:532024-08-05 11:37:55

Judging History

你现在查看的是最新测评结果

  • [2024-08-05 11:37:55]
  • 评测
  • [2024-08-05 11:37:53]
  • 提交

answer

#pragma GCC optimize("Ofast")
#pragma GCC target("avx2,popcnt")

#include <bits/stdc++.h>

using namespace std;

#define endl "\n"

constexpr int mod = 1e8;

int n, m, mp[101];

vector<int> state;

void init() {
	for (int i = 0; i < (1 << m); ++i) {
		if (i & (i << 1)) continue;
		if (i & (i << 2)) continue;
		state.push_back(i);
	}
}

unordered_map<int, unordered_map<int, int>> dp[101];

//int dp[101][1024][1024];

#define pop_count(x) __builtin_popcount(x)

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(nullptr);
	cin >> n >> m;
	for (int i = 1; i <= n; ++i) {
		string str;
		cin >> str;
		for (int j = 0; j < m; ++j) {
			mp[i] |= (str[j] == 'H') << j;
		}
	}
	init();
	dp[0][0][0] = 0;
	for (int i = 1; i <= n; ++i) {
		for (int a : state) {
			if (a & mp[i]) continue;
			for (int b : state) {
				if (a & b) continue;
				if (b & mp[i - 1]) continue;
				for (int c : state) {
					if (a & c) continue;
					if (b & c) continue;
					dp[i][a][b] = max(dp[i][a][b], dp[i - 1][b][c] + pop_count(a));
				}
			}
		}
	}
	int ans = 0;
	for (int a : state) for (int b : state) ans = max(ans, dp[n][a][b]);
	cout << ans << endl;
	return 0;
}

詳細信息

In file included from /usr/include/c++/13/string:43,
                 from /usr/include/c++/13/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:52,
                 from answer.code:4:
/usr/include/c++/13/bits/allocator.h: In destructor ‘constexpr std::__cxx11::basic_string<char>::_Alloc_hider::~_Alloc_hider()’:
/usr/include/c++/13/bits/allocator.h:184:7: error: inlining failed in call to ‘always_inline’ ‘constexpr std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = char]’: target specific option mismatch
  184 |       ~allocator() _GLIBCXX_NOTHROW { }
      |       ^
In file included from /usr/include/c++/13/string:54:
/usr/include/c++/13/bits/basic_string.h:181:14: note: called from here
  181 |       struct _Alloc_hider : allocator_type // TODO check __is_final
      |              ^~~~~~~~~~~~