QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#323076#4828. Four Plus Fourduongnc0000 0ms0kbC++203.3kb2024-02-08 12:49:042024-02-08 12:49:06

Judging History

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

  • [2024-02-08 12:49:06]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:0kb
  • [2024-02-08 12:49:04]
  • 提交

answer

/*
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx2,fma,bmi,bmi2,sse4.2,popcnt,lzcnt")
*/

#include <bits/stdc++.h>
#define taskname ""
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define i64 long long
#define pb push_back
#define ff first
#define ss second
#define isz(x) (int)x.size()
using namespace std;

const int mxN = 2e5 + 5;
const int mod = 1e9 + 7;
const i64 oo = 1e18;

vector<array<int, 3>> vec;
map<pair<int, int>, int> mp;
vector<string> dict8, dict4;

void prep() {
    for (int i = 1; i < 32; i <<= 1) {
        for (int a1 = i; a1 < i << 1; ++a1) {
            for (int j = i * 2; j + i * 2 - 1 <= 3919; j += i * 2) {
                for (int loop = 0; loop < i; ++loop) {
                    vec.push_back({a1, j + loop, (j + loop + a1 >= j + i * 2 ? j + loop + a1 - i : j + loop + a1)});
                    mp[{vec.back()[0], vec.back()[1]}] = mp[{vec.back()[1], vec.back()[0]}] = isz(vec) - 1;
                    mp[{vec.back()[0], vec.back()[2]}] = mp[{vec.back()[2], vec.back()[0]}] = isz(vec) - 1;
                    mp[{vec.back()[1], vec.back()[2]}] = mp[{vec.back()[2], vec.back()[1]}] = isz(vec) - 1;
                }
            }
        }
    }
}

void password() {
    int n; cin >> n;
    vector<string> v;
    for (int i = 1; i <= n; ++i) {
        string s; cin >> s;
        v.emplace_back(s);
    }

    cin >> n;
    for (int i = 1; i <= n; ++i) {
        string s; cin >> s;
        dict8.emplace_back(s);
    }
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        string s; cin >> s;
        dict4.emplace_back(s);
    }

    for (auto s : v) {
        auto [x, y, z] = vec[lower_bound(all(dict8), s) - dict8.begin()];
        cout << dict4[x] << " " << dict4[y] << " " << dict4[z] << "\n";
    }
}

void keys() {
    int n; cin >> n;
    vector<pair<string, string>> v;
    for (int i = 1; i <= n; ++i) {
        string s, t; cin >> s >> t;
        v.emplace_back(s, t);
    }

    cin >> n;
    for (int i = 1; i <= n; ++i) {
        string s; cin >> s;
        dict8.emplace_back(s);
    }
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        string s; cin >> s;
        dict4.emplace_back(s);
    }

    for (auto [s, t] : v) {
        int x = lower_bound(all(dict4), s) - dict4.begin();
        int y = lower_bound(all(dict4), t) - dict4.begin();
        cout << dict8[mp[{x, y}]] << "\n";
    }
}

string name;

void solve() {
    cin >> name;
    if (name == "password") password();
    else keys();
}

signed main() {

#ifndef CDuongg
    if(fopen(taskname".inp", "r"))
        assert(freopen(taskname".inp", "r", stdin)), assert(freopen(taskname".out", "w", stdout));
#else
    freopen("bai3.inp", "r", stdin);
    freopen("bai3.out", "w", stdout);
    auto start = chrono::high_resolution_clock::now();
#endif

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    prep(); 
    int t = 1; //cin >> t;
    while(t--) solve();

#ifdef CDuongg
   auto end = chrono::high_resolution_clock::now();
   cout << "\n"; for(int i = 1; i <= 100; ++i) cout << '=';
   cout << "\nExecution time: " << chrono::duration_cast<chrono::milliseconds> (end - start).count() << "[ms]" << endl;
   cout << "Check array size pls sir" << endl;
#endif

}

詳細信息

Test #1:

score: 0
Wrong Answer on the first run

input:

password
2
password
couthier
28558
aardvark aardwolf aasvogel abacuses abalones abampere abandons abapical abasedly abashing abatable abatises abattoir abbacies abbatial abbesses abdicate abdomens abdomina abducens abducent abducing abducted abductee abductor abelmosk aberrant abetment abettals abet...

output:

abos yowl yups
abba sway swig

input:


output:


result:

wrong answer abos didn't appear in password