QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#275233#7882. Linguistics PuzzlezzzYhengCompile Error//C++142.6kb2023-12-04 15:24:192023-12-04 15:24:20

Judging History

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

  • [2023-12-04 15:24:20]
  • 评测
  • [2023-12-04 15:24:19]
  • 提交

answer

#pragma GCC optimize("Ofast,no-stack-protector,fast-math", 3)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tune=native")

#include <bits/stdc++.h>

using namespace std;

using namespace std;

const int kMaxN = 55;

int T;

int n;

vector<string> P, Q, QQ;

pair<int, int> cntP[kMaxN];
pair<int, int> cntQ[kMaxN];

vector<int> vec[kMaxN];

int p[kMaxN];

bool vis[kMaxN];

string ans;

void dfs(int now) {
	if (now == n) {
		QQ.clear();
		for (int i = 0; i < n * n; ++i) {
			string s;
			for (int j = 0; j < P[i].size(); ++j) {
				s += p[P[i][j]];
			}
			QQ.emplace_back(s);
		}
		sort(QQ.begin(), QQ.end());
		//for (string it : QQ) cout << it << ' ';
		//cout << '\n';
		if (QQ == Q) {
			ans = "";
			for (int i = 0; i < n; ++i) {
				if (p[i] < 26) ans += 'a' + p[i];
				else ans += 'A' + p[i] - 26;
			}
			return;
		}
		return;
	}
	for (auto it : vec[now]) {
		if (!vis[it]) {
			vis[it] = 1;
			p[now] = it;
			dfs(now + 1);
			if (ans != "flag") return;
			vis[it] = 0;
		}
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	
	cin >> T;
	while (T--) {
		cin >> n;
		P.clear(), Q.clear();
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < n; ++j) {
				int x = i * j;
				string s;
				if (x < n) {
					s += x;
				}
				else {
					s += x / n;
					s += x % n;
				}
				P.emplace_back(s);
			}
		}
		for (int i = 0; i < n * n; ++i) {
			string s;
			cin >> s;
			for (int i = 0; i < s.size(); ++i) {
				if ('a' <= s[i] && s[i] <= 'z') s[i] = s[i] - 'a';
				else s[i] = s[i] - 'A' + 26;
			}
			Q.emplace_back(s);
		}
		sort(P.begin(), P.end());
		sort(Q.begin(), Q.end());
		//for (int i = 0; i < n * n; ++i) cout << P[i] << ' ';
		//cout << '\n';
		//for (int i = 0; i < n * n; ++i) cout << Q[i] << ' ';
		//cout << '\n';
		fill(cntP, cntP + n, make_pair(0, 0));
		fill(cntQ, cntQ + n, make_pair(0, 0));
		for (string it : P) {
			++cntP[it[0]].first;
			if (it.size() > 1) ++cntP[it[1]].first;
		}
			//cout << "( " << i << ' ' << cntP[i].first << ' ' << cntP[i].second << '\n';
		for (string it : Q) {
			++cntQ[it[0]].first;
			if (it.size() > 1) ++cntQ[it[1]].first;
		}
			//cout << ") " << i << ' ' << cntQ[i].first << ' ' << cntQ[i].second << '\n';
		for (int i = 0; i < n; ++i) vec[i].clear();
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < n; ++j) {
				if (cntP[i] == cntQ[j]) {
					//cout << "* " << i << ' ' << j << '\n';
					vec[i].emplace_back(j);
				}
			}
		}
		ans = "flag";
		fill(vis, vis + n, 0);
		dfs(0);
		cout << ans << '\n';
	}
	return 0;
}

Details

In file included from /usr/include/x86_64-linux-gnu/c++/11/bits/gthr.h:148,
                 from /usr/include/c++/11/ext/atomicity.h:35,
                 from /usr/include/c++/11/bits/ios_base.h:39,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from answer.code:4:
/usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:102:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
  102 | __gthrw(pthread_once)
      | ^~~~~~~
/usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:102:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
/usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:103:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
  103 | __gthrw(pthread_getspecific)
      | ^~~~~~~
/usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:103:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
/usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:104:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
  104 | __gthrw(pthread_setspecific)
      | ^~~~~~~
/usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:104:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
/usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:106:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
  106 | __gthrw(pthread_create)
      | ^~~~~~~
/usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:106:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
/usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:107:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
  107 | __gthrw(pthread_join)
      | ^~~~~~~
/usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:107:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
/usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:108:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
  108 | __gthrw(pthread_equal)
      | ^~~~~~~
/usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:108:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
/usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:109:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
  109 | __gthrw(pthread_self)
      | ^~~~~~~
/usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:109:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
/usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:110:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
  110 | __gthrw(pthread_detach)
      | ^~~~~~~
/usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:110:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
/usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:112:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
  112 | __gthrw(pthread_cancel)
      | ^~~~~~~
/usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:112:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
/usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:114:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
  114 | __gthrw(sched_yield)
      | ^~~~~~~
/usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:114:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
/usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:116:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
  116 | __gthrw(pthread_mutex_lock)
      | ^~~~~~~
/usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:116:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
/usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:117:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
  117 | __gthrw(pthread_mutex_trylock)
      | ^~~~~~~
/usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:117:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
/usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:119:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
  119 | __gthrw(pthread_mutex_timedlock)
      | ^~~~~~~
/usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:119:1: error: attribute value ‘tune=native’ was already specified in ‘target’ attribute
/usr/...