結果

問題 No.1788 Same Set
ユーザー beetbeet
提出日時 2021-12-17 00:37:07
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,099 bytes
コンパイル時間 4,288 ms
コンパイル使用メモリ 210,488 KB
実行使用メモリ 62,732 KB
最終ジャッジ日時 2023-10-12 00:44:02
合計ジャッジ時間 13,185 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 80 ms
34,652 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 80 ms
34,652 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 80 ms
34,676 KB
testcase_10 AC 80 ms
34,700 KB
testcase_11 AC 116 ms
37,708 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 299 ms
62,528 KB
testcase_18 AC 290 ms
62,548 KB
testcase_19 AC 303 ms
62,564 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 171 ms
37,472 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

// multiset dato godoku sita

#include <bits/stdc++.h>
using namespace std;

using Int = long long;
const char newl = '\n';

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}
template<typename T=Int>
vector<T> read(size_t n){
  vector<T> ts(n);
  for(size_t i=0;i<n;i++) cin>>ts[i];
  return ts;
}

//INSERT ABOVE HERE
const Int MAX = 4e5+10;
const Int T = 10;
Int rnd[T][MAX];


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  Int n;
  cin>>n;

  auto as=read(n);
  auto bs=read(n);

  random_device seed;
  mt19937 mt(seed());
  uniform_int_distribution<Int> ud(1,1e9);

  for(Int t=0;t<T;t++)
    for(Int i=0;i<MAX;i++)
      rnd[t][i]=ud(mt);

  using A = array<Int, T>;
  map<A, Int> cnt;
  A sum;
  fill(sum.begin(),sum.end(),0);

  Int ans=0;
  for(Int i=0;i<n;i++){
    cnt[sum]++;
    for(Int t=0;t<T;t++)
      sum[t]+=rnd[t][as[i]]-rnd[t][bs[i]];
    ans+=cnt[sum];
  }

  cout<<ans<<endl;
  return 0;
}
0