結果

問題 No.2288 Somen Sliders
ユーザー cureskolcureskol
提出日時 2023-04-27 23:03:21
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 94 ms / 2,000 ms
コード長 1,016 bytes
コンパイル時間 2,485 ms
コンパイル使用メモリ 210,672 KB
実行使用メモリ 54,784 KB
最終ジャッジ日時 2024-04-28 22:53:51
合計ジャッジ時間 4,395 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 55 ms
20,864 KB
testcase_11 AC 33 ms
16,640 KB
testcase_12 AC 59 ms
24,320 KB
testcase_13 AC 74 ms
30,848 KB
testcase_14 AC 70 ms
28,288 KB
testcase_15 AC 45 ms
10,880 KB
testcase_16 AC 16 ms
5,376 KB
testcase_17 AC 13 ms
5,376 KB
testcase_18 AC 20 ms
5,376 KB
testcase_19 AC 21 ms
5,376 KB
testcase_20 AC 22 ms
5,376 KB
testcase_21 AC 22 ms
5,376 KB
testcase_22 AC 94 ms
54,784 KB
testcase_23 AC 83 ms
50,688 KB
testcase_24 AC 4 ms
5,376 KB
testcase_25 AC 14 ms
5,376 KB
testcase_26 AC 5 ms
5,376 KB
testcase_27 AC 13 ms
5,376 KB
testcase_28 AC 11 ms
5,376 KB
testcase_29 AC 7 ms
5,376 KB
testcase_30 AC 17 ms
5,376 KB
testcase_31 AC 8 ms
5,376 KB
testcase_32 AC 7 ms
5,376 KB
testcase_33 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0