求助
查看原帖
求助
741139
Dreamer_Boy楼主2022/12/31 11:06

错误代码

#include <bits/stdc++.h>
using namespace std;
string s[110];
char r[110];
int t[110];

int main() {
	int T;
	cin >> T;
	while (T--) {
		int n, m;

		cin >> n >> m;
		for (int i = 1; i <= m; i++) {
			t[i] = 1;
			cin >> s[i] >> r[i];
		}
		int ans = 0;
		while (ans < m) {
			for (int i = 0; i < n; i++) {
				int now = -1;
				bool f = 1;
				for (int j = 1; j <= m; j++) {
					if (t[j] && s[j][i] == '0') {
						if (now == -1)
							now = r[j];
						if (r[j] != now)
							f = 0;
					}
				}
				if (f) {
					for (int j = 1; j <= m; j++) {
						if (s[j][i] == '0')
							t[i] = 0;
					}
				}
				now = -1, f = 1;
				for (int j = 1; j <= m; j++) {
					if (t[j] && s[j][i] == '1') {
						if (now == -1)
							now = r[j];
						if (r[j] != now)
							f = 0;
					}
				}
				if (f) {
					for (int j = 1; j <= m; j++) {
						if (s[j][i] == '0')
							t[i] = 0;
					}
				}
			}
			int now = 0;
			for (int i = 1; i <= m; i++) {
				ans += (t[i] == 0);
			}
			if (now == ans) {
				break;
			}
			ans = now;
		}
		if (ans == m) {
			puts("OK");

		} else
			puts("LTE");


	}
	return 0;
}
2022/12/31 11:06
加载中...