結果
| 問題 |
No.1673 Lamps on a line
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-09-10 21:29:40 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 148 ms / 2,000 ms |
| コード長 | 1,197 bytes |
| コンパイル時間 | 1,822 ms |
| コンパイル使用メモリ | 169,428 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-11 22:33:15 |
| 合計ジャッジ時間 | 3,316 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 11 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define MOD int(1e9)+7
#define MOD2 int(998244353)
#define INF int(1e9)+7
#define LINF ll(1e18)+7
#define PI acos(-1)
#define P pair<ll,ll>
template <typename T>
inline bool chmax(T &a, const T &b){
if(a<b) {a=b; return true;}
else return false;
}
template <typename T>
inline bool chmin(T &a, const T &b){
if(a>b) {a=b; return true;}
else return false;
}
//Graph
struct Edge{
int to; ll cost;
Edge(int _to, ll _cost) : to(_to), cost(_cost) {}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
void add_edge(Graph &g,int from,int to,ll cost,bool rev,ll rev_cost){
g[from].push_back(Edge(to,cost));
if(rev) g[to].push_back(Edge(from,rev_cost));
}
int n,q;
int light[510000];
void solve(){
cin>>n>>q;
int sum=0;
while(q--){
int l,r;
cin>>l>>r;
l--;
for(int i=l; i<r; i++){
if(light[i]==0){
light[i]=1; sum++;
}else{
light[i]=0; sum--;
}
}
cout<<sum<<endl;
}
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cout<<setprecision(10)<<fixed;
solve();
return 0;
}