CSES - Siperia opettaa 5.0 - Results
Submission details
Task:Distribution Center
Sender:kh
Submission time:2017-03-09 16:59:24 +0200
Language:C++
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:57:14: error: 'it' was not declared in this scope
              it = j.lower_bound(x);
              ^

Code

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

ll n, m;
map<ll, set<ll> >p;

int main() {
	cin >> n >> m;
	for (ll i = 0; i<=n; i++) {
	    set<ll> e;
	    p[i] = e; 
	}
	for (ll i = 1; i<=m; i++) {
	    ll x, y;
	    cin >> x >> y;
	    p[y].insert(x);
	}
	for (ll i = 1; i<=n; i++) {
	    ll t = 1;
	    ll y = i-1;
	    ll x = 0;
	    set<ll> s = p[y];
	    if (y > 0 && !s.empty()) {
	    auto it = s.end();
	        t++; //cout << "a ";
	        it--;
	        //cout << *it << "k ";
	        
	        while (true) {
	            x = *it;
	            //cout << x << "l ";
	            y--;
	            set<ll>k = p[y];
	            if (y <= 0 || k.empty()) break;
	            it = k.lower_bound(x);
	            it--;
	            //cout << *it << " " << x << "h ";
	            //prev = *it;
	            if (*it > x || *it <= 0) break;
	            else t++; //cout << "b ";
	        }
	    }
	    y = i;
	    if (y < n) {
	    set<ll> l = p[y];
	    if (!l.empty()) {
	        t++; //cout << "c ";
	        auto ite = l.end();
	        ite--;
	        while (true) {
	            x = *ite;
	            y++;
	            set<ll> j = p[y];
	            if (y >= n || j.empty()) break;
	            it = j.lower_bound(x);
	            ite--;
	            //cout << *it << " " << x << "d ";
	            if (*ite > x || *ite <= 0) break;
	            else t++; //cout << "e ";
	        }
	    }
	    }
	    cout << t << " ";
	   
	}
	cout << "\n";
	return 0;
}