Submission #524015


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<<18)-1];

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
Task B - ドキドキデート大作戦高橋君
User okaduki
Language C++11 (GCC 4.9.2)
Score 0
Code Size 2501 Byte
Status
Exec Time 550 ms
Memory 6304 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 subtask0_sample_01.txt, subtask0_sample_02.txt, subtask0_sample_03.txt
Subtask1 0 / 30 subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask0_sample_01.txt, subtask0_sample_02.txt, subtask0_sample_03.txt
All 0 / 70 subtask0_sample_01.txt, subtask0_sample_02.txt, subtask0_sample_03.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask2_01.txt, subtask2_02.txt, subtask2_03.txt, subtask2_04.txt, subtask2_05.txt, subtask2_06.txt, subtask2_07.txt, subtask2_08.txt
Case Name Status Exec Time Memory
subtask0_sample_01.txt 26 ms 804 KB
subtask0_sample_02.txt 25 ms 928 KB
subtask0_sample_03.txt 25 ms 924 KB
subtask1_01.txt 402 ms 5664 KB
subtask1_02.txt 312 ms 5660 KB
subtask1_03.txt 113 ms 5664 KB
subtask1_04.txt 269 ms 6056 KB
subtask1_05.txt 276 ms 6048 KB
subtask1_06.txt 25 ms 800 KB
subtask1_07.txt 25 ms 796 KB
subtask1_08.txt 25 ms 804 KB
subtask1_09.txt 25 ms 800 KB
subtask2_01.txt 311 ms 5676 KB
subtask2_02.txt 313 ms 5668 KB
subtask2_03.txt 25 ms 924 KB
subtask2_04.txt 25 ms 928 KB
subtask2_05.txt 25 ms 800 KB
subtask2_06.txt 29 ms 920 KB
subtask2_07.txt 25 ms 920 KB
subtask2_08.txt 550 ms 6304 KB