QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#372789#3657. Fantasy Draft_SIGMA#WA 1ms3840kbC++142.2kb2024-03-31 19:14:482024-03-31 19:14:50

Judging History

This is the latest submission verdict.

  • [2024-03-31 19:14:50]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 3840kb
  • [2024-03-31 19:14:48]
  • Submitted

answer

#include<bits/stdc++.h>
#include<unordered_map> 
#define print(v,T) copy(v.begin(), v.end(), ostream_iterator<T>(cout, " "));
#define TATAKAAI ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define el "\n"
#define ell cout<<"\n"
#define forn(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define forb(i, n) for (int i = n-1; i >= 0; i--)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;

const ll N = 1000000007;
int dy[] = { 1,-1,0,0,1,-1 };
int dx[] = { 0,0,-1,1,1,-1 };

int main() {
    TATAKAAI;

    ll n, k;
    cin >> n >> k;
    int x;
    map<string, vector<pair<ll,ll>>>mp;
    // idx,par
    string s;
    forn(i, n) {
        cin >> x;
        forn(j, x) {
            cin >> s;
            mp[s].push_back({ j,i });
        }
    }   
    int q;
    cin >> q;
    vector<string>v(q + 5);
    forn(i, q) {
        cin >> v[i];
    }
    for (auto it : mp)sort(all(it.second));
    //forn(i, q) {
    //    cout << v[i] << el;
    //    for (auto it : mp[v[i]]) {
    //        cout << it.first << " " << it.second << el;
    //    }
    //    ell;
    //}
    map<int, vector<string>>ans;
    vector<bool>vis(q, 0);
    ll turn = 0;
    forn(i, q) {
        if (!mp.count(v[i]))continue;
        else {
            for (auto it : mp[v[i]]) {
                if (ans[it.second].size() < k &&!vis[i] ) {
                    ans[it.second].push_back(v[i]);
                    vis[i] = 1;
                    break;
                }
            }
        }
    }
    int j = 0;
    while(j<q){
       // cout << v[j] << " " << vis[j] << " " << turn << el;
        bool bb = 1;
        forn(i,n){
            if (ans[i].size() < k)bb = 0;
        }
        if (bb)break;
        if (vis[j])j++;
        else if (!vis[j] && ans[turn].size() < k) {
            ans[turn].push_back(v[j]);
            vis[j] = 1;
            turn = (turn + 1) % n;
            j++;
        }
        else if (!vis[j]) {
            turn = (turn + 1) % n;
        }
    }
    forn(i, n) {
        for (auto gg : ans[i])cout << gg << " ";
        ell;
    }



    return 0;
}

详细

Test #1:

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

input:

2 2
0
0
6
Shoresy
Jonesy
Reilly
Sholtzy
Fisky
Yorkie

output:

Shoresy Reilly 
Jonesy Sholtzy 

result:

ok 2 lines

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 3840kb

input:

2 2
2 Reilly Shoresy
2 Shoresy Reilly
6
Shoresy
Jonesy
Reilly
Sholtzy
Fisky
Yorkie

output:

Shoresy Reilly 
Jonesy Sholtzy 

result:

wrong answer 1st lines differ - expected: 'Reilly Jonesy', found: 'Shoresy Reilly '