結果
| 問題 |
No.1673 Lamps on a line
|
| コンテスト | |
| ユーザー |
ekaraage
|
| 提出日時 | 2021-08-02 13:10:11 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 190 ms / 2,000 ms |
| コード長 | 1,001 bytes |
| コンパイル時間 | 3,880 ms |
| コンパイル使用メモリ | 250,544 KB |
| 最終ジャッジ日時 | 2025-01-23 13:41:47 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 11 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long MOD2 = 998244353;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
template<class T> inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
int main(){
ll N, Q;
cin >> N >> Q;
vector<ll> A(N, 0);
assert(N <= 500000);
assert(Q <= 100000);
ll ans = 0;
while (Q--) {
ll l, r;
cin >> l >> r;
assert(1 <= l and l <= N);
assert(l <= r and r <= N);
assert(r - l <= 10);
l--;
r--;
for (ll i = l; i <= r;i++){
A[i] ^= 1;
if (A[i] == 1)
ans++;
else
ans--;
}
cout << ans << endl;
}
}
ekaraage