結果
| 問題 |
No.1765 While Shining
|
| コンテスト | |
| ユーザー |
Nachia
|
| 提出日時 | 2021-11-27 00:11:24 |
| 言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 18 ms / 2,000 ms |
| コード長 | 782 bytes |
| コンパイル時間 | 2,810 ms |
| コンパイル使用メモリ | 111,512 KB |
| 最終ジャッジ日時 | 2025-01-26 02:04:15 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#include <atcoder/modint>
using namespace std;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
#define rep(i,n) for(int i=0; i<(n); i++)
using m32 = atcoder::static_modint<998244353>;
int main(){
int N; cin >> N;
vector<int> A(N);
rep(i,N) cin >> A[i];
vector<int> ans(N);
int wall[2] = { N-1, N-1 };
for(int i=N-1; i>=0; i--){
wall[A[i] ^ (i%2)] = i;
ans[i] = wall[i%2] - i;
}
i64 sumans = 0;
for(auto a : ans) sumans += a;
cout << sumans << endl;
return 0;
}
struct ios_do_not_sync {
ios_do_not_sync() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
}
} ios_do_not_sync_instance;
Nachia