結果
| 問題 |
No.2288 Somen Sliders
|
| コンテスト | |
| ユーザー |
cureskol
|
| 提出日時 | 2023-04-27 23:03:21 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 94 ms / 2,000 ms |
| コード長 | 1,016 bytes |
| コンパイル時間 | 2,245 ms |
| コンパイル使用メモリ | 205,064 KB |
| 最終ジャッジ日時 | 2025-02-12 14:31:32 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n,x,y;cin>>n>>x>>y;
vector<pair<int,int>> P(n,{-1,-1}), match(x);
vector<stack<int>> Q(y);
REP(i1,x){
int k;cin>>k;
match[i1]={-1,k};
REP(j1,k+1){
int u;cin>>u;u--;
if(clamp(u,0,n-1)==u)
P[u]={i1,j1};
}
}
REP(i2,y){
int l;cin>>l;
REP(j2,l+1){
int v;cin>>v;v--;
if(clamp(v,0,n-1)==v and ~P[v].first)
Q[i2].push(v);
}
}
queue<int> que;
REP(i2,y)que.push(i2);
while(que.size()){
int i2=que.front();que.pop();
while(Q[i2].size()){
int v=Q[i2].top();Q[i2].pop();
const auto&[i1,j1]=P[v];
const auto&[now_i2, now_j1] = match[i1];
if(now_j1 > j1){
if(~now_i2)
que.push(now_i2);
match[i1] = {i2, j1};
break;
}
}
}
int ans=0;
for(const auto&[_,score]:match)
ans += score;
cout<<ans<<endl;
}
cureskol