QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#482773 | #3657. Fantasy Draft | Youssef# | RE | 0ms | 3808kb | C++14 | 3.5kb | 2024-07-17 21:28:05 | 2024-07-17 21:28:05 |
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 test() {
ll n, k;
cin >> n >> k;
vector<queue<string>> v(n);
vector<vector<string>> ans(n);
for(int i =0;i<n;i++)
{
int a ;
cin>>a ;
for(int j=0;j<a ;j++)
{
string s ;
cin>>s ;
v[j].push(s);
}
}
int q ;
cin>>q;
unordered_set<string> st ;
while(q--)
{
string s ;
cin>>s ;
st.insert(s);
}
for(auto i:st)
{
cout <<i <<" ";
}
while(k--)
{
for(int i =0;i<n;i++)
{
if(v[i].size())
{
while(true)
{
if(st.find(v[i].front()) != st.end())
{
ans[i].push_back(v[i].front());
st.erase(v[i].front());
v[i].pop();
break;
}
v[i].pop();
if(!v[i].size())
{
ans[i].push_back(*st.begin());
st.erase(*st.begin());
break;
}
}
}
else {
ans[i].push_back(*st.begin());
st.erase(*st.begin());
}
}
}
for(int i=0;i<n;i++)
{
for(auto j : ans[i])
{
//cout<<j<<" ";
}
cout<<"\n";
}
}
string simp(string s)
{
string ans;
int l = s.size();
for (int i = 0; i < l; ++i) {
char ch = s[i];
ans.push_back(ch);
i++;
for(; i < l; i++)
{
if(ch != s[i])
break;
}
i--;
}
return ans;
}
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(k, 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 < k; ++j) {
cout << ans[i][j] << ((j == k - 1) ? "" : " ");
}
cout << ((i == n - 1) ? "" : "\n");
}
}
signed main() {
int t = 1;
//cin >> t;
while (t--)
kero();
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3808kb
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: 0ms
memory: 3640kb
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: 3636kb
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: 3640kb
input:
1 1 1 Jonesy 2 Reilly Jonesy
output:
Jonesy
result:
ok single line: 'Jonesy'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3644kb
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