Submission #1501744
Source Code Expand
#include <bits/stdc++.h> #define rep(n) for (int I = 0; (I) < (n); ++(I) ) #define repeat(i, n) for( int i = 0; (i) < (n); ++(i) ) #define repeat_to(i, n) for( int i = 0; (i) <= (n); ++(i) ) #define repeat_from(i, m, n) for( int i = (m); (i) < (n); ++(i) ) #define repeat_from_to(i, m, n) for( int i = (m); (i) <= (n); ++(i) ) #define repeat_from_reverse(i, m, n) for( int i = (n) - 1; (i) >= (m); --(i) ) #define dump(x) cout << " " << #x << "=" << x #define vdump(v) for(size_t t=0; t<v.size(); ++t){cout << " " << #v << "[" << t << "]=" << v[t];} cout << endl using namespace std; using lint = long long; using ld = long double; // セグメントツリー (点変更・区間クエリ) template <typename monoid> struct segment_tree { using M = monoid; using T = typename M::value_type; size_t sz; vector<T> x; segment_tree(size_t n = 0) { sz = 1; while (sz < n) sz *= 2; x.assign(sz * 2, M::id()); initialize(); } template <typename iterator> segment_tree(iterator first, iterator last) { sz = 1; size_t n = distance(first, last); while (sz < n) sz *= 2; x.assign(sz * 2, M::id()); copy(first, last, x.begin() + sz); initialize(); } void fill(const T& val) { std::fill(x.begin() + sz, x.end(), val); initialize(); } void initialize() { for (int i = (int)sz - 1; i >= 1; --i) { x[i] = M::op(x[i * 2 + 0], x[i * 2 + 1]); } } T accumulate(size_t l, size_t r) const { T al = M::id(), ar = M::id(); for (l += sz, r += sz; l < r; l /= 2, r /= 2) { if (l & 1) al = M::op(al, x[l++]); if (r & 1) ar = M::op(x[--r], ar); } return M::op(al, ar); } void update(size_t i, const T &val) { x[i += sz] = val; while (i > 1) { x[i / 2] = M::op(x[i], x[i ^ 1]); i /= 2; } } T operator[](size_t i) const { return x[sz + i]; } }; template <typename T> struct min_monoid { using value_type = T; static constexpr T id() { return numeric_limits<T>::max(); } static T op(const T &a, const T &b) { return min(a, b); } }; template <typename T> struct max_monoid { using value_type = T; static constexpr value_type id() { return numeric_limits<value_type>::min(); } static value_type op(const value_type &a, const value_type &b) { return max(a, b); } }; template <typename T> struct sum_monoid { using value_type = T; static constexpr value_type id() { return 0; } static value_type op(const value_type &a, const value_type &b) { return a + b; } }; template <typename value_type> using rmq = segment_tree<min_monoid<value_type>>; template <typename value_type> using rsq = segment_tree<sum_monoid<value_type>>; int main(void){ int a[N]={0}; int s[100003]; int t[100003]; int ans[100003]; int n,m; cin>>n>>m; for(int i=0;i<m;i++){ cin>>s[i]>>t[i]; a[s[i]]++; a[t[i]+1]--; } int k=0; for(int i=0;i<=n;i++){ a[i+1]+=a[i]; } //for(int i=0;i<=n;i++)printf("%d\n",a[i]); for(int i=0;i<=n;i++){ if(a[i]!=1)a[i]=0; } for(int i=0;i<=n;i++){ a[i+1]+=a[i]; } int j; for(int i=0;i<m;i++){ if(a[t[i]]-a[s[i]-1]==0){ ans[k]=i+1; k++; } } printf("%d\n",k); for(int i=0;i<k;i++){ printf("%d\n",ans[i]); } return 0; }
Submission Info
Submission Time | |
---|---|
Task | B - ドキドキデート大作戦高橋君 |
User | maphylageo |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 3657 Byte |
Status | CE |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:99:11: error: ‘N’ was not declared in this scope int a[N]={0}; ^ ./Main.cpp:107:9: error: ‘a’ was not declared in this scope a[s[i]]++; ^ ./Main.cpp:112:9: error: ‘a’ was not declared in this scope a[i+1]+=a[i]; ^ ./Main.cpp:116:12: error: ‘a’ was not declared in this scope if(a[i]!=1)a[i]=0; ^ ./Main.cpp:119:9: error: ‘a’ was not declared in this scope a[i+1]+=a[i]; ^ ./Main.cpp:123:12: error: ‘a’ was not declared in this scope if(a[t[i]]-a[s[i]-1]==0){ ^