QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#95754#5603. Three Dicetriplem5ds#WA 2ms3532kbC++202.7kb2023-04-11 19:55:482023-04-11 19:55:51

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-11 19:55:51]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3532kb
  • [2023-04-11 19:55:48]
  • 提交

answer

///Enta etfsh5t nseet el rank

#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,fma")

#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
        tree_order_statistics_node_update>;
#define pb push_back
#define F first
#define S second
#define f(i, a, b) for (int i = a; i < b; i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sz(x) (int)(x).size()
//#define mp(x, y) make_pair(x, y)
#define popCnt(x) (__builtin_popcountll(x))
#define int ll

using ll = long long;
using ull = unsigned long long;
using uint = uint32_t;
using ii = pair<int, int>;

const int N = 1e5 + 20, LG = 18, MOD = (119 << 23) + 1;
const long double PI = acos(-1);

const long double EPS = 1e-9;

string s[1005];
vector<int> adj[256];
string toAssign;
int col[256];
int cnt[3];

void bt(int index) {
    if (index == toAssign.size()) {
        string s[3];
        f(i, 0, 18)s[col[toAssign[i]]].push_back(toAssign[i]);
        cout << s[0] << ' ' << s[1] << ' ' << s[2] << endl;
        ::exit(0);
    }
    bool can[3] = {cnt[0] != 6, cnt[1] != 6, cnt[2] != 6};
    for (auto x: adj[toAssign[index]])
        if (col[x] != -1) {
            can[col[x]] = false;
        }

    f(i, 0, 3)if (can[i]) {
            col[toAssign[index]] = i;
            cnt[i] += 1;
            bt(index + 1);
            cnt[i] -= 1;
        }
    col[toAssign[index]] = -1;
}

void doWork() {
    ::memset(col, -1, sizeof col);

    int n;
    cin >> n;
    set<char> st;
    f(i, 0, n) {
        cin >> s[i];
        st.insert(s[i][0]);
        st.insert(s[i][1]);
        st.insert(s[i][2]);
    }
    if (st.size() > 18) {
        cout << "0\n";
    }
    f(i, 0, n) {
        if (s[i][0] == s[i][1] || s[i][0] == s[i][2] || s[i][1] == s[i][2]) {
            cout << "0\n";
            return;
        }
        f(j, 0, 3)f(k, 1, 3)adj[s[i][j]].push_back(s[i][k]),
                        adj[s[i][k]].push_back(s[i][j]);
    }

    for (char c: st)toAssign.push_back(c);
    for (char c = 'a'; c <= 'z' && toAssign.size() < 18; c++) {
        if (st.count(c))continue;
        toAssign.push_back(c);
    }
    bt(0);
    cout << "0\n";
}

int32_t main() {
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif // ONLINE_JUDGE
    int t = 1;
//    cin >> t;
    while (t--)
        doWork();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3480kb

input:

3
lad
fin
sly

output:

afsbce diyghj lnkmop

result:

ok correct

Test #2:

score: 0
Accepted
time: 0ms
memory: 3532kb

input:

1
dad

output:

0

result:

ok impossible

Test #3:

score: 0
Accepted
time: 0ms
memory: 3504kb

input:

11
aft
cog
far
irk
kit
yes
tau
rag
own
uke
via

output:

acknsb eortvd fgiuwy

result:

ok correct

Test #4:

score: 0
Accepted
time: 2ms
memory: 3500kb

input:

20
aah
aal
aas
aba
abo
abs
aby
ace
act
add
ado
ads
adz
aff
aft
aga
age
ago
aha
aid

output:

0

result:

ok impossible

Test #5:

score: -100
Wrong Answer
time: 2ms
memory: 3456kb

input:

23
abc
acb
bac
bca
cab
cba
abd
adb
bad
bda
dab
dba
acd
adc
cad
cda
dac
dca
fgh
ijk
lmn
opq
rst

output:

0
0

result:

wrong output format Extra information in the output file