QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#372751#3657. Fantasy Draft_SIGMA#WA 1ms3828kbC++141.8kb2024-03-31 18:27:082024-03-31 18:27:08

Judging History

This is the latest submission verdict.

  • [2024-03-31 18:27:08]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 3828kb
  • [2024-03-31 18:27:08]
  • 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, pair<int, int>>mp;
    // idx,par
    string s;
    forn(i, n) {
        cin >> x;
        forn(j, x) {
            cin >> s;
            if (!mp.count(s)) {
                mp[s] = { j,i };
            }
            else {
                if (mp[s].first > j) {
                    mp[s] = { j,i };
                }
            }
        }
    }
    int q;
    cin >> q;
    vector<string>v(q + 5);
    forn(i, q) {
        cin >> v[i];
    }
    map<int, vector<string>>ans;
    vector<bool>vis(q, 0);
    forn(i, q) {
        if (!mp.count(v[i]))continue;
        else {
            if (ans[mp[v[i]].second].size() < k) {
                ans[mp[v[i]].second].push_back(v[i]);
                vis[i] = 1;
                mp.erase(v[i]);
            }
        }
    }
    int turn = 0;
    forn(j, q) {
        if (!vis[j] && ans[turn].size() < k) {
            ans[turn].push_back(v[j]);
            vis[j] = 1;
            turn = (turn + 1) % n;
        }
    }
    forn(i, n) {
        for (auto gg : ans[i])cout << gg << " ";
        ell;
    }



    return 0;
}

详细

Test #1:

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

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: 3580kb

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: 3828kb

input:

1 1
0
1
Jonesy

output:

Jonesy 

result:

ok single line: 'Jonesy '

Test #4:

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

input:

1 1
1 Jonesy
1
Jonesy

output:

Jonesy 

result:

ok single line: 'Jonesy '

Test #5:

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

input:

1 1
1 Jonesy
2
Reilly
Jonesy

output:

Jonesy 

result:

ok single line: 'Jonesy '

Test #6:

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

input:

1 1
1 Reilly
2
Reilly
Jonesy

output:

Reilly 

result:

ok single line: 'Reilly '

Test #7:

score: -100
Wrong Answer
time: 0ms
memory: 3588kb

input:

1 2
2 Jonesy Reilly
2
Reilly
Jonesy

output:

Reilly Jonesy 

result:

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