結果

問題 No.1788 Same Set
ユーザー tute7627
提出日時 2021-11-14 10:53:13
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 674 bytes
コンパイル時間 2,111 ms
コンパイル使用メモリ 199,712 KB
最終ジャッジ日時 2025-01-25 17:54:22
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 2
other AC * 1 WA * 6 RE * 22 TLE * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

int main(){
  int n;
  cin >> n;
  vector<int>a(n), b(n);
  for(int i = 0; i < n; i++)cin >> a[i];
  for(int i = 0; i < n; i++)cin >> b[i];
  bitset<200005>c, d;
  long long ans = 0;
  for(int i = 0; i < n; i++){
    //c = 0, d = 0;
    int cnt = 0;
    for(int j = i; j < n; j++){
      if(!c[a[j]]){
        if(d[a[j]])cnt--;
        else cnt++;
        c[a[j]] = true;
      }
      if(!d[b[j]]){
        if(c[b[j]])cnt--;
        else cnt++;
        d[b[j]] = true;
      }
      if(cnt == 0)ans++;
    }
  }
  cout << ans << endl;
}
0