Drkcore

13 08 2008 cpp topcoder Tweet

SRM200-DIV2-1000

WindowManager

class WindowManager {
public:
  vector <string> screen(int height, int width, vector <string> windows) {
    vector <string> result;
    stringstream ss;
    int lx,ly,rx,ry;
    char c;
    result.clear();
    string s;
    s.clear();
    s = "";
    //    cout << width << "," << height << endl;
    for(int a=0;a<width;++a) s += " ";
    for(int b=0;b<height;++b) result.push_back(s);

    for(int i = 0;i<windows.size();++i) {
      ss.str(windows[i]);
      ss >> ly >> lx >> ry >> rx >> c;
      rx += lx -1;
      ry += ly -1;

      for(int y=0;y<height;++y) {
    for(int x=0;x<width;++x) {
      if((x==lx && y==ly) ||(x==lx && y==ry) ||(x==rx && y==ly) ||(x==rx && y==ry)) {
        result[y][x] = '+';
      }
      else if(((x == lx)||(x == rx)) && (y > ly) && (y < ry)) {
        result[y][x] = '|';
      }
      else if(((y == ly)||(y == ry)) && (x >lx) && (x < rx)) {
        result[y][x] = '-';
      }
      else if((x >lx) && (x < rx) && (y > ly) && (y < ry)){
        result[y][x] = c;
      }
        }
      }
      ss.str("");
      ss.clear();
    }
    return result;
  } 
};

About

  • もう5年目(wishlistありマス♡)
  • 最近はPythonとDeepLearning
  • 日本酒自粛中
  • ドラムンベースからミニマルまで
  • ポケモンGOゆるめ

Tag

Python Deep Learning javascript chemoinformatics Emacs sake and more...

Ad

© kzfm 2003-2021