結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 127 ms
20,864 KB
testcase_11 AC 95 ms
16,768 KB
testcase_12 AC 151 ms
24,320 KB
testcase_13 AC 222 ms
30,848 KB
testcase_14 AC 200 ms
28,288 KB
testcase_15 AC 71 ms
10,624 KB
testcase_16 AC 18 ms
5,376 KB
testcase_17 AC 16 ms
5,376 KB
testcase_18 AC 22 ms
5,376 KB
testcase_19 AC 22 ms
5,376 KB
testcase_20 AC 22 ms
5,376 KB
testcase_21 AC 23 ms
5,376 KB
testcase_22 AC 312 ms
54,912 KB
testcase_23 AC 288 ms
50,688 KB
testcase_24 AC 3 ms
5,376 KB
testcase_25 AC 15 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 8 ms
5,376 KB
testcase_30 AC 19 ms
5,376 KB
testcase_31 AC 8 ms
5,376 KB
testcase_32 AC 8 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;

  constexpr pair<int,int> null{-1,-1};
  vector<pair<int,int>> P(n,null);
  vector<pair<int,int>> 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)continue;
      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 or P[v]==null)continue;
      Q[i2].push(v);
    }
  }

  queue<int> que;
  REP(i2,y)que.push(i2);
  while(que.size()){
    int i2=que.front();que.pop();
    cerr<<i2<<'\n';
    while(Q[i2].size()){
      int v=Q[i2].top();Q[i2].pop();
      auto [i1,j1]=P[v];
      if(match[i1].second > j1){
        if(~match[i1].first)
          que.push(match[i1].first);
        match[i1] = {i2, j1};
        break;
      }
    }
  }

  int ans=0;
  for(const auto&[_,score]:match)ans+=score;
  cout<<ans<<'\n';
}



  
0