結果
問題 |
No.2779 Don't make Pair
|
ユーザー |
|
提出日時 | 2024-06-07 22:49:05 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 882 bytes |
コンパイル時間 | 6,658 ms |
コンパイル使用メモリ | 336,296 KB |
実行使用メモリ | 13,380 KB |
最終ジャッジ日時 | 2024-12-26 09:16:23 |
合計ジャッジ時間 | 10,177 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 WA * 1 |
other | AC * 20 WA * 4 |
ソースコード
#include <bits/stdc++.h> using namespace std; #include <atcoder/all> using namespace atcoder; #define ll long long #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) using mint = modint998244353; const int dx[4]={0,1,0,-1}; const int dy[4]={1,0,-1,0}; int n; int main(){ cin >> n; vector<int> a(n); rep(i,n) cin >> a[i]; map<int,int>mp,mp2; rep(i,n) mp[a[i]]++; int pair_cnt=0; for(auto p:mp){ if(p.second>2){ cout << 0 << endl; return 0; } if(p.second==2) pair_cnt++; } vector<int>ans; rep(i,n-1){ if(mp[a[i]]==2)pair_cnt--; mp[a[i]]--; mp2[a[i]]++; if(mp2[a[i]]==2) pair_cnt++; if(pair_cnt==0){ ans.push_back(i+1); } } cout << ans.size() << endl; rep(i,ans.size()) cout << ans[i] << " "; cout<<endl; return 0; }