QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#482791 | #3657. Fantasy Draft | Youssef# | RE | 1ms | 3872kb | C++14 | 1.8kb | 2024-07-17 21:34:16 | 2024-07-17 21:34:17 |
Judging History
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) {
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();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3624kb
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: 3828kb
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: 0ms
memory: 3568kb
input:
1 1 0 1 Jonesy
output:
Jonesy
result:
ok single line: 'Jonesy'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3568kb
input:
1 1 1 Jonesy 1 Jonesy
output:
Jonesy
result:
ok single line: 'Jonesy'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3560kb
input:
1 1 1 Jonesy 2 Reilly Jonesy
output:
Jonesy
result:
ok single line: 'Jonesy'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3872kb
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