Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <cstdio>
- #include <cstdlib>
- #include <string>
- using namespace std;
- int arr[1000];
- void clear(){
- for(int i = 0; i < 1000; i++){
- arr[i] = 0;
- }
- }
- int getMaxHeight(int xmin, int xmax){
- int h = arr[xmin];
- for(int i = xmin+1; i < xmax; i++){
- if(arr[i] > h){
- h = arr[i];
- }
- }
- return h;
- }
- int main() {
- string fname, line;
- cin >> fname;
- ifstream inputFile(fname.c_str());
- int t, b, xmin, xmax, h, maxh, ht;
- inputFile >> t;
- for(int i = 0; i < t; i++){
- clear();
- //cout << t << endl;
- inputFile >> b;
- //cout << b << endl;
- for(int i = 0; i < b; i++){
- inputFile >> xmin;
- inputFile >> xmax;
- inputFile >> h;
- maxh = getMaxHeight(xmin, xmax);
- //cout << xmin << " " << xmax << " " << h << " " << maxh << endl;
- for(int j = xmin; j < xmax; j++){
- arr[j] = maxh+h;
- }
- }
- // search contour
- int prevHeight = 0, prevXmin = 0;
- cout << "(0,0) ";
- for(int i = 0; i < 1000; i++){
- if(arr[i] != prevHeight){
- cout << "(" << i << "," << prevHeight << ") " ;
- cout << "(" << i << "," << arr[i] << ") " ;
- }
- prevHeight = arr[i];
- prevXmin = i;
- }
- cout << "(1000,0)" << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement