QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#196803 | #6370. Slot Machine | SayedHassan | WA | 20ms | 11500kb | C++14 | 1.4kb | 2023-10-01 23:16:37 | 2023-10-01 23:16:37 |
Judging History
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'