请求加强数据!!!
查看原帖
请求加强数据!!!
1058410
Gcc_Gdb_7_8_1楼主2024/8/27 22:17

这份代码第一次提交是用 C++14 (GCC 9) 吸了氧提交的,AC,然鹅复杂度是 O(n2m)O(n^2m), 我以为是卡过了,于是关了氧气,结果仍然AC,于是我换了 C++20 且不吸氧,还是AC

Code:

#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

string strs[3010];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= n; ++i) {
		cin >> strs[i];
		sort(strs[i].begin(), strs[i].end(), greater<char>());
	}
	for (int i = 1; i <= n; ++i) {
		reverse(strs[i].begin(), strs[i].end());
		bool flag = true;
		for (int j = 1; j <= n; ++j) {
			if (i != j && strs[j] <= strs[i]) {
				cout << "0";
				flag = false;
				break;
			}
		}
		if (flag) {
			cout << "1";
		}
		reverse(strs[i].begin(), strs[i].end());
	}
	return 0;
}
2024/8/27 22:17
加载中...