結果
問題 | No.1673 Lamps on a line |
ユーザー |
![]() |
提出日時 | 2021-12-31 10:41:32 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 545 bytes |
コンパイル時間 | 1,823 ms |
コンパイル使用メモリ | 191,616 KB |
最終ジャッジ日時 | 2025-01-27 08:02:37 |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 6 RE * 5 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i=0;i<n;i++) int p[100010]; signed main(){ int ans=0; int n,q;cin>>n>>q; rep(qq,q){ int l; int r; cin>>l>>r; l--;r--; int oncount=0; int offcount=0; for(int i=l;i<=r;i++){ if(p[i]==0){ p[i]=1; offcount++; continue; } if(p[i]==1){ p[i]=0; oncount++; } } ans=ans+offcount-oncount; //cout<<p[0]<<p[1]<<p[2]<<p[3]<<p[4]<<endl; cout<<ans<<endl; } return 0; }