Contest Duration: ~ (local time) (90 minutes) Back to Home

Submission #523785

Source Code Expand

Copy
```#include <bits/stdc++.h>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int NN = 1;
struct Node{
int dat;
int lazy;
};
Node segT[2*(1<<17)-1]; // =131072

class LazySegT{
public:
LazySegT(){
for(int i=0;i<2*NN-1;++i)
segT[i].dat = 0, segT[i].lazy = -1;
}

void eval(int k, int l, int r){
// 評価する必要がない
if(segT[k].lazy < 0) return;

segT[k].dat += segT[k].lazy;
if(k < NN-1){ // not leaf
segT[2*k+1].lazy = segT[k].lazy;
segT[2*k+2].lazy = segT[k].lazy;
}
segT[k].lazy = -1;
}

// dat += c, a <= idx < b
void update(int a, int b, int c, int k=0, int l=0, int r=NN){
eval(k,l,r);
if(r <= a || b <= l) return;

if(a <= l && r <= b){
segT[k].lazy = c;
eval(k,l,r);
}
else{
update(a, b, c, k*2+1, l, (l+r)/2);
update(a, b, c, k*2+2, (l+r)/2, r);
segT[k].dat = min(segT[k*2+1].dat, segT[k*2+2].dat);
}
}

int query(int a, int b, int k=0, int l=0, int r=NN){
eval(k,l,r);
// no intersect
if(r <= a || b <= l) return 1e9;

// completely contain
if(a <= l && r <= b) return segT[k].dat;
else{
int vl = query(a, b, k*2+1, l, (l+r)/2);
int vr = query(a, b, k*2+2, (l+r)/2, r);
return min(vl, vr);
}
}
};

int main(){
cin.tie(0);
ios_base::sync_with_stdio(false);

int N, M; cin >> N >> M;
vector<PII> xs(M);
REP(i,M) cin >> xs[i].first >> xs[i].second;

while(NN < N) NN <<= 1;
LazySegT seg;
REP(i,M) seg.update(xs[i].first, xs[i].second+1, 1);

VI ans;
REP(i,M)
if(seg.query(xs[i].first, xs[i].second+1) > 1)
ans.PB(i);

cout << SZ(ans) << endl;
for(int x: ans)
cout << x+1 << endl;

return 0;
}
```

#### Submission Info

Submission Time 2015-10-10 21:29:08+0900 B - ドキドキデート大作戦高橋君 okaduki C++11 (GCC 4.9.2) 0 2512 Byte WA 464 ms 3628 KB

#### Test Cases

Set Name Score / Max Score Test Cases
Case Name Status Exec Time Memory