QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#482795#3657. Fantasy DraftYoussef#RE 1ms3784kbC++141.8kb2024-07-17 21:37:092024-07-17 21:37:09

Judging History

This is the latest submission verdict.

  • [2024-07-17 21:37:09]
  • Judged
  • Verdict: RE
  • Time: 1ms
  • Memory: 3784kb
  • [2024-07-17 21:37:09]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
#define Seny ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v) v.begin(),v.end()
#define print(v) for(auto x : v)cout<<x<<" "
#define ll long long
#define int ll
#define endl '\n'
const int mod = 1e9 + 7;
const int N = 2e5 + 5;

void kero()
{
    int n, k;
    cin >> n >> k;
    vector<queue<string>> prio(n);
    set<string> taken;
    for (int i = 0; i < n; ++i) {
        int t; cin >> t;
        while (t--) {
            string inp; cin >> inp;
            prio[i].push(inp);
        }
    }
    int p; cin >> p;
    deque<string> strs(p);
    for(int i = 0; i < p; i++)
        cin >> strs[i];
    vector<vector<string>> ans(n, vector<string>());
    for (int j = 0; j < n*k; ++j) {
            if(j >= p)
                break;
            int i = j % k;
            if(prio[i].size()) {
                while (prio[i].size() and taken.count(prio[i].front()))
                    prio[i].pop();
                if(prio[i].size()){
                    ans[i].push_back(prio[i].front());
                    taken.insert(prio[i].front());
                    prio[i].pop();
                    continue;
                }
            }
            while (strs.size() and taken.count(strs.front()))
                strs.pop_front();
        if(strs.size()){
            ans[i].push_back((strs.front()));
            taken.insert((strs.front()));
            strs.pop_front();
        }


    }
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < ans[i].size(); ++j) {
            cout << ans[i][j] << ((j == ans[i].size() - 1) ? "\n" : " ");
        }
//        cout << ((i == n - 1) ? "" : "\n");
    }
}
signed main() {
    Seny
    int t = 1;
    //cin >> t;
    while (t--)
        kero();
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3712kb

input:

2 2
0
0
6
Shoresy
Jonesy
Reilly
Sholtzy
Fisky
Yorkie

output:

Shoresy Reilly
Jonesy Sholtzy

result:

ok 2 lines

Test #2:

score: 0
Accepted
time: 1ms
memory: 3716kb

input:

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

output:

Reilly Jonesy
Shoresy Sholtzy

result:

ok 2 lines

Test #3:

score: 0
Accepted
time: 1ms
memory: 3604kb

input:

1 1
0
1
Jonesy

output:

Jonesy

result:

ok single line: 'Jonesy'

Test #4:

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

input:

1 1
1 Jonesy
1
Jonesy

output:

Jonesy

result:

ok single line: 'Jonesy'

Test #5:

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

input:

1 1
1 Jonesy
2
Reilly
Jonesy

output:

Jonesy

result:

ok single line: 'Jonesy'

Test #6:

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

input:

1 1
1 Reilly
2
Reilly
Jonesy

output:

Reilly

result:

ok single line: 'Reilly'

Test #7:

score: -100
Runtime Error

input:

1 2
2 Jonesy Reilly
2
Reilly
Jonesy

output:


result: