QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#196803#6370. Slot MachineSayedHassanWA 20ms11500kbC++141.4kb2023-10-01 23:16:372023-10-01 23:16:37

Judging History

你现在查看的是最新测评结果

  • [2023-10-01 23:16:37]
  • 评测
  • 测评结果:WA
  • 用时:20ms
  • 内存:11500kb
  • [2023-10-01 23:16:37]
  • 提交

answer

#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx,avx2,fma")


using namespace std;
#define ll long long
const int N=1e5+5;
int a[N],n;
vector<int> adj[N];
set<pair<int,int> >s[N];
int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin>>n;
    int ans=N;
	for(int i=1;i<=n;i++)
    {
        int m;
        cin>>m;
        map<int,int> mp;
        int cnt=0;
        for(int j=0;j<m;j++)
        {
            int x;
            cin>>x;
            adj[i].push_back(x);
            mp[x]++;
            if(mp[x]==1)cnt++;
        }
        for(auto x:mp)
        {
            s[x.first].insert({cnt,i});
        }
        if(cnt<m)ans=min(ans,cnt+1);
        sort(adj[i].begin(),adj[i].end());
    }
    for(int i=1;i<=n;i++)
    {
        vector<int> v;
        for(auto x:adj[i])
        {

            if(s[x].begin()->second==i)
            {
                pair<int,int> pr=*s[x].begin();
                s[x].erase(s[x].begin());
                if(s[x].empty())v.push_back(1e8);
                else v.push_back(s[x].begin()->first);
                s[x].insert(pr);
            }
            else
            {
                v.push_back(s[x].begin()->first);
            }
        }
        sort(v.begin(),v.end(),greater<int>());
        for(int j=0;j<v.size();j++)ans=min(ans,v[j]+j+1);
    }
    cout<<ans;
	return 0;

}

詳細信息

Test #1:

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

input:

7
4 1 2 3 4
1 1
1 2
1 3
1 4
7 4 7 4 4 7 7 4
1 5

output:

2

result:

ok 1 number(s): "2"

Test #2:

score: -100
Wrong Answer
time: 20ms
memory: 11500kb

input:

10
1 971
1 472
1 799
1 68
1 729
1 592
1 616
1 148
1 188
99991 18 79 923 610 734 650 745 482 627 651 914 251 785 787 949 204 400 2 365 569 623 536 508 341 398 840 371 450 332 223 36 578 850 857 192 474 309 933 457 162 200 140 802 462 40 957 553 640 302 748 532 323 593 239 657 425 17 584 924 903 413 3...

output:

1001

result:

wrong answer 1st numbers differ - expected: '993', found: '1001'