QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#321815 | #4828. Four Plus Four | socpite | Compile Error | / | / | C++14 | 4.1kb | 2024-02-05 17:11:01 | 2024-02-05 17:11:01 |
Judging History
answer
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("arch=skylake")
#include<bits/stdc++.h>
using namespace std;
const int MAX4 = 3919;
const int MAX8 = 28558;
const int MAXN = 1e5+5;
int id[MAX8];
string dict8[MAX8];
string dict4[MAX4];
int edg[MAX4][MAX4];
int deg[MAX4];
array<string, 3> encode[MAX8];
vector<int> subset[MAX8];
char f_a[MAX8][26], f_b[MAX4][26];
pair<string, string> keys[MAXN];
string passwords[MAXN];
map<pair<string, string>, string> mp;
map<string, int> pos_p;
bool check_key(const int a, const int b){
for(int i = 0; i < 26; i++)if(f_a[a][i] < f_b[b][i])return false;
return true;
}
bool cmp_d(int a, int b){
return deg[a] < deg[b];
}
bool cmp(int a, int b){
return subset[a].size() < subset[b].size();
}
vector<string> priority = {"unliving", "ungluing", "glugging"};
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
string type;
cin >> type;
int dummy;
int n;
cin >> n;
if(type == "password")for(int i = 0; i < n; i++)cin >> passwords[i];
else for(int i = 0; i < n; i++)cin >> keys[i].first >> keys[i].second;
cin >> dummy;
for(int i = 0; i < MAX8; i++){
cin >> dict8[i];
for(auto v: dict8[i])f_a[i][v-'a']++;
pos_p[dict8[i]] = i;
}
cin >> dummy;
for(int i = 0; i < MAX4; i++){
cin >> dict4[i];
for(auto v: dict4[i])f_b[i][v-'a']++;
}
for(int i = 0; i < MAX8; i++){
id[i] = i;
for(int j = 0; j < MAX4; j++){
if(check_key(i, j))subset[i].push_back(j);
}
}
sort(id, id + MAX8, cmp);
int progress = 0;
for(int i = 0; i < priority.size(); i++){
for(int j = 0; j < MAX8; j++)if(dict8[id[j]] == priority[i]){
swap(id[j], id[i]);
break;
}
}
for(auto v: id){
progress++;
sort(subset[v].begin(), subset[v].end(), cmp_d);
// cout << progress << " " << subset[v].size() << endl;
if(subset[v].size() < 3)continue;
for(int i = 0; i < subset[v].size(); i++){
if(!edg[subset[v][i]][subset[v][i]]){
edg[subset[v][i]][subset[v][i]] = 1;
deg[subset[v][i]]++;
for(int j = 0; j < 3; j++)encode[v][j] = dict4[subset[v][i]];
break;
}
bool found = 0;
for(int j = i+1; j < subset[v].size(); j++){
if(edg[subset[v][i]][subset[v][j]])continue;
for(int k = j+1; k < subset[v].size(); k++){
if(edg[subset[v][i]][subset[v][k]])continue;
if(edg[subset[v][j]][subset[v][k]])continue;
edg[subset[v][i]][subset[v][j]] = 1;
edg[subset[v][j]][subset[v][i]] = 1;
edg[subset[v][i]][subset[v][k]] = 1;
edg[subset[v][k]][subset[v][i]] = 1;
edg[subset[v][j]][subset[v][k]] = 1;
edg[subset[v][k]][subset[v][j]] = 1;
encode[v][0] = dict4[subset[v][i]];
encode[v][1] = dict4[subset[v][j]];
encode[v][2] = dict4[subset[v][k]];
deg[subset[v][i]]+=2;
deg[subset[v][j]]+=2;
deg[subset[v][k]]+=2;
found = 1;
break;
}
if(found)break;
}
if(found)break;
}
}
if(type == "password"){
for(int i = 0; i < n; i++){
for(int j = 0; j < 3; j++)cout << encode[pos_p[passwords[i]]][j] << " ";
cout << "\n";
}
}
else{
for(int i = 0; i < MAX8; i++){
if(encode[i].empty())continue;
for(int j = 0; j < 3; j++){
for(int k = 0; k < 3; k++){
if(j == k)continue;
mp[make_pair(encode[i][j], encode[i][k])] = dict8[i];
}
}
}
for(int i = 0; i < n; i++)cout << mp[keys[i]] << "\n";
}
}
詳細信息
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:3: /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:102:1: error: attribute value ‘arch=skylake’ 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 ‘arch=skylake’ was already specified in ‘target’ attribute /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:103:1: error: attribute value ‘arch=skylake’ 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 ‘arch=skylake’ was already specified in ‘target’ attribute /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:104:1: error: attribute value ‘arch=skylake’ 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 ‘arch=skylake’ was already specified in ‘target’ attribute /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:106:1: error: attribute value ‘arch=skylake’ 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 ‘arch=skylake’ was already specified in ‘target’ attribute /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:107:1: error: attribute value ‘arch=skylake’ 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 ‘arch=skylake’ was already specified in ‘target’ attribute /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:108:1: error: attribute value ‘arch=skylake’ 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 ‘arch=skylake’ was already specified in ‘target’ attribute /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:109:1: error: attribute value ‘arch=skylake’ 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 ‘arch=skylake’ was already specified in ‘target’ attribute /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:110:1: error: attribute value ‘arch=skylake’ 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 ‘arch=skylake’ was already specified in ‘target’ attribute /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:112:1: error: attribute value ‘arch=skylake’ 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 ‘arch=skylake’ was already specified in ‘target’ attribute /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:114:1: error: attribute value ‘arch=skylake’ 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 ‘arch=skylake’ was already specified in ‘target’ attribute /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:116:1: error: attribute value ‘arch=skylake’ 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 ‘arch=skylake’ was already specified in ‘target’ attribute /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:117:1: error: attribute value ‘arch=skylake’ 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 ‘arch=skylake’ was already specified in ‘target’ attribute /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:119:1: error: attribute value ‘arch=skylake’ 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 ‘arch=skylake’ was already specified i...