题解:CF2009B osu!mania

每次读入一个字符串,枚举哪一个位置出现了 #,倒序存入答案数组,然后正序输出即可。

代码:

#include<bits/stdc++.h>
using namespace std;

int main() {
	int t;
	cin >> t;
	while (t--) {
		int n;
		cin >> n;
		vector<int> result(n);
		for (int i = 0; i < n; ++i) {
			string row;
			cin >> row;
			for (int j = 0; j < 4; ++j) {
				if (row[j] == '#') {
					result[n - i - 1] = j + 1;
				}
			}
		}
		for (int i = 0; i < n; ++i) {
			cout << result[i] << " ";
		}
		cout << endl;
	}
	return 0;
}
posted @ 2024-10-02 18:57  cly312  阅读(27)  评论(0)    收藏  举报