alexjercan/bugnet huggingface dataset:
Problem p00026 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>

#define SIZE 10

using namespace std;

int map[SIZE][SIZE] = {0};

void drop(int x, int y) {
  if (0 <= x && x < SIZE && 0 <= y && y < SIZE) {
    map[x][y]++;
  }
}

int main() {
  int x, y, s, count = 0, most = 0;
  char e;
  while (cin >> x >> e >> y >> e >> s) {
    drop(x, y);
    drop(x, y + 1);
    drop(x + 1, y);
    drop(x, y - 1);
    drop(x - 1, y);

    if (s > 1) {
      drop(x + 1, y + 1);
      drop(x + 1, y - 1);
      drop(x - 1, y - 1);
      drop(x - 1, y + 1);
    }

    if (s > 2) {
      drop(x, y + 2);
      drop(x, y - 2);
      drop(x + 2, y);
      drop(x - 2, y);
    }
  }

  for (int i = 0; i < SIZE; i++) {
    for (int j = 0; j < SIZE; j++) {
      if (map[i][j] > most) {
        most = map[i][j];
      }

      if (map[i][j] == 0) {
        count++;
      }
    }
  }

  cout << count << endl << most << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <cstdio>
#include <iostream>

#define SIZE 10

using namespace std;

int map[SIZE][SIZE];

void drop(int x, int y) {
  if (x < 0 || y < 0 || x >= SIZE || y >= SIZE)
    return;

  map[x][y]++;
}

int main() {
  int x, y, s, count = 0, most = 0;

  while (scanf("%d,%d,%d", &x, &y, &s)) {
    x--;
    y--;
    drop(x, y);
    drop(x, y + 1);
    drop(x + 1, y);
    drop(x, y - 1);
    drop(x - 1, y);

    if (s > 1) {
      drop(x + 1, y + 1);
      drop(x + 1, y - 1);
      drop(x - 1, y - 1);
      drop(x - 1, y + 1);

      if (s > 2) {
        drop(x, y + 2);
        drop(x, y - 2);
        drop(x + 2, y);
        drop(x - 2, y);
      }
    }
  }

  for (int i = 0; i < SIZE; i++) {
    for (int j = 0; j < SIZE; j++) {
      if (map[i][j] > most) {
        most = map[i][j];
      }

      if (map[i][j] == 0) {
        count++;
      }
    }
  }

  cout << count << endl << most << endl;
  return 0;
}
Problem p00026 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;

int map[10][10] = {};
int sx[] = {0, -1, 0, 1, 0}, sy[] = {-1, 0, 0, 0, 1};
int mx[] = {-1, 0, 1}, my[] = {-1, 0, 1};
int lx[] = {0, -1, 0, 1, -2, -1, 0, 1, 2, -1, 0, 1, 0};
int ly[] = {-2, -1, -1, -1, 0, 0, 0, 0, 0, 1, 1, 1, 2};

int main() {

  int x, y, size;
  char temp;
  int empty = 0, max = 0;

  while (1) {
    cin >> x;
    if (cin.eof())
      break;
    cin >> temp >> y;
    cin >> temp >> size;

    if (size == 1) {
      for (int i = 0; i < 5; i++) {
        if (x + sx[i] >= 0 && x + sx[i] <= 9 && y + sy[i] >= 0 &&
            y + sy[i] <= 9)
          map[x + sx[i]][y + sy[i]]++;
      }
    } else if (size == 2) {
      for (int i = 0; i < 9; i++) {
        if (x + mx[i % 3] >= 0 && x + mx[i % 3] <= 9 && y + my[i / 3] >= 0 &&
            y + my[i / 3] <= 9)
          map[x + mx[i % 3]][y + my[i / 3]]++;
      }
    } else if (size == 3) {
      for (int i = 0; i < 13; i++) {
        if (x + lx[i] >= 0 && x + lx[i] <= 9 && y + ly[i] >= 0 &&
            y + ly[i] <= 9)
          map[x + lx[i]][y + ly[i]]++;
      }
    }
  }

  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      if (map[i][j] == 0)
        empty++;
      if (map[i][j] > max)
        max = map[i][j];
    }
  }

  cout << empty << endl;
  cout << max << endl;

  return 0;
}

Error: WA

Fixed submission:

#include <iostream>
using namespace std;

int map[10][10] = {};
int sx[] = {0, -1, 1, 0}, sy[] = {-1, 0, 0, 1};
int mx[] = {-1, 0, 1}, my[] = {-1, 0, 1};
int lx[] = {0, -1, 0, 1, -2, -1, 1, 2, -1, 0, 1, 0};
int ly[] = {-2, -1, -1, -1, 0, 0, 0, 0, 1, 1, 1, 2};

int main() {

  int x, y, size;
  char temp;
  int empty = 0, max = 0;

  while (1) {
    cin >> x;
    if (cin.eof())
      break;
    cin >> temp >> y;
    cin >> temp >> size;

    map[x][y]++;

    if (size == 1) {
      for (int i = 0; i < 4; i++) {
        if (x + sx[i] >= 0 && x + sx[i] <= 9 && y + sy[i] >= 0 &&
            y + sy[i] <= 9)
          map[x + sx[i]][y + sy[i]]++;
      }
    } else if (size == 2) {
      for (int i = 0; i < 9; i++) {
        if (x + mx[i % 3] >= 0 && x + mx[i % 3] <= 9 && y + my[i / 3] >= 0 &&
            y + my[i / 3] <= 9)
          map[x + mx[i % 3]][y + my[i / 3]]++;
      }
    } else if (size == 3) {
      for (int i = 0; i < 12; i++) {
        if (x + lx[i] >= 0 && x + lx[i] <= 9 && y + ly[i] >= 0 &&
            y + ly[i] <= 9)
          map[x + sx[i]][y + sy[i]]++;
      }
    }
  }

  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      if (map[i][j] == 0)
        empty++;
      if (map[i][j] > max)
        max = map[i][j];
    }
  }

  cout << empty << endl;
  cout << max << endl;

  return 0;
}
Problem p00026 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int main() {
  int a[15][15] = {0}, b = 0, c = 0, x, y, t;
  string s[50];
  while (scanf("%d,%d,%d", &x, &y, &t) != EOF) {
    if (t == 3) {
      a[x + 2][y + 2]++;
      a[x + 1][y + 2]++;
      a[x][y + 2]++;
      a[x + 3][y + 2]++;
      a[x + 4][y + 2]++;
      a[x + 2][y + 1]++;
      a[x + 2][y]++;
      a[x + 2][y + 3]++;
      a[x + 2][y + 4]++;
      a[x + 3][y + 3]++;
      a[x + 3][y + 1]++;
      a[x + 1][y + 3]++;
      a[x + 1][y + 1]++;
    } else if (t == 2) {
      a[x + 2][y + 2]++;
      a[x + 1][y + 2]++;
      a[x + 3][y + 2]++;
      a[x + 2][y + 1]++;
      a[x + 2][y + 3]++;
      a[x + 3][y + 3]++;
      a[x + 3][y + 1]++;
      a[x + 1][y + 3]++;
      a[x + 1][y + 1]++;
    } else {
      a[x + 2][y + 2]++;
      a[x + 1][y + 2]++;
      a[x + 3][y + 2]++;
      a[x + 2][y + 1]++;
      a[x + 2][y + 3]++;
    }
  }
  for (int i = 2; i < 12; i++) {
    for (int j = 2; j < 12; j++) {
      if (!a[i][j])
        c++;
      b = max(b, a[i][j]);
    }
  }
  cout << c << endl << b << endl;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int a[15][15] = {0}, b = 0, c = 0, x, y, t;
  string s[50];
  while (scanf("%d,%d,%d", &x, &y, &t)) {
    if (t == 3) {
      a[x + 2][y + 2]++;
      a[x + 1][y + 2]++;
      a[x][y + 2]++;
      a[x + 3][y + 2]++;
      a[x + 4][y + 2]++;
      a[x + 2][y + 1]++;
      a[x + 2][y]++;
      a[x + 2][y + 3]++;
      a[x + 2][y + 4]++;
      a[x + 3][y + 3]++;
      a[x + 3][y + 1]++;
      a[x + 1][y + 3]++;
      a[x + 1][y + 1]++;
    }
    if (t == 2) {
      a[x + 2][y + 2]++;
      a[x + 1][y + 2]++;
      a[x + 3][y + 2]++;
      a[x + 2][y + 1]++;
      a[x + 2][y + 3]++;
      a[x + 3][y + 3]++;
      a[x + 3][y + 1]++;
      a[x + 1][y + 3]++;
      a[x + 1][y + 1]++;
    } else {
      a[x + 2][y + 2]++;
      a[x + 1][y + 2]++;
      a[x + 3][y + 2]++;
      a[x + 2][y + 1]++;
      a[x + 2][y + 3]++;
    }
  }
  for (int i = 2; i < 13; i++) {
    for (int j = 2; j < 13; j++) {
      if (!a[i][j])
        c++;
      b = max(b, a[i][j]);
    }
  }
  cout << b << endl << c << endl;
}
Problem p00026 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

int main() {

  int s3x[12] = {0, 1, 0, -1, 1, 1, -1, -1, 0, 2, 0, -2};
  int s3y[12] = {1, 0, -1, 0, 1, -1, 1, -1, 2, 0, -2, 0};

  vector<vector<int>> p(10, vector<int>(10, 0));
  int x, y, s;
  int cnt = 0;
  int mx = 0;

  while (scanf("%d,%d,%d", &x, &y, &s) != EOF) {
    p[x][y]++;
    mx = max(mx, p[x][y]);
    cnt++;
    for (int i = 0; i < s * 4; i++) {
      int tx = x + s3x[i];
      int ty = y + s3y[i];
      if (tx < 0 || ty < 0 || tx >= 10 || ty >= 10)
        continue;
      p[tx][ty]++;
      cnt++;
      mx = max(mx, p[tx][ty]);
    }
    // cerr << cnt << endl;
  }
  int ans = 0;
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      if (p[i][j] == 0)
        ans++;
    }
  }
  cout << ans << endl;
  cout << mx << endl;
  return 0;
}

// EOF

Error: WA

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

int main() {

  int s3x[12] = {0, 1, 0, -1, 1, 1, -1, -1, 0, 2, 0, -2};
  int s3y[12] = {1, 0, -1, 0, 1, -1, 1, -1, 2, 0, -2, 0};

  vector<vector<int>> p(10, vector<int>(10, 0));
  int x, y, s;
  int cnt = 0;
  int mx = 0;
  // while( cin >> x >> y >> s ){
  while (scanf("%d,%d,%d\\n", &x, &y, &s) != EOF) {
    p[x][y]++;
    cnt++;
    for (int i = 0; i < s * 4; i++) {
      int tx = x + s3x[i];
      int ty = y + s3y[i];
      if (tx < 0 || ty < 0 || tx >= 10 || ty >= 10)
        continue;
      p[tx][ty]++;
      cnt++;
      mx = max(mx, p[tx][ty]);
    }
    cerr << cnt << endl;
  }
  cout << cnt << endl;
  cout << mx << endl;
  return 0;
}

// EOF
Problem p00026 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int margin = 3;
const int paper_size = 10;
int cordx[] = {0, 0, -1, 0, 1, -1, -1, 1, 1, 0, -2, 0, 2};
int cordy[] = {0, -1, 0, 1, 0, -1, 1, 1, -1, -2, 0, 2, 0};

int main(int argc, char **argv) {
  vvi paper(paper_size + margin * 2, vi(paper_size + margin * 2, 0));
  int x, y, size;
  char com;
  for (;;) {
    cin >> x >> com >> y >> com >> size;
    if (cin.eof())
      break;

    for (int i = 0; i < 1 + 4 * size; i++) {
      paper[margin + x + cordx[i]][margin + y + cordy[i]]++;
    }
  }

  int empty_nr = 0;
  int max_score = 0;
  for (int i = margin; i < margin + paper_size; i++) {
    for (int j = margin; j < margin + paper_size; j++) {
      if (paper[i][j]) {
        max_score = max(max_score, paper[i][j]);
      } else {
        empty_nr++;
      }
    }
  }
  cout << empty_nr << endl;
  cout << max_score << endl;

  return 0;
}

Error: WA

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int margin = 2;
const int paper_size = 10;
int cordx[] = {0, 0, -1, 0, 1, -1, -1, 1, 1, 0, -2, 0, 2};
int cordy[] = {0, -1, 0, 1, 0, -1, 1, 1, -1, -2, 0, 2, 0};

int main(int argc, char **argv) {
  vvi paper(paper_size + margin, vi(paper_size + margin, 0));
  int x, y, size;
  char com;
  for (;;) {
    cin >> x >> com >> y >> com >> size;
    if (cin.eof())
      break;

    for (int i = 0; i < 1 + 4 * size; i++) {
      paper[margin + x + cordx[i]][margin + y + cordy[i]]++;
    }
  }

  int empty_nr = 0;
  int max_score = 0;
  for (int i = margin; i < margin + paper_size; i++) {
    for (int j = margin; j < margin + paper_size; j++) {
      if (paper[i][j]) {
        max_score = max(max_score, paper[i][j]);
      } else {
        empty_nr++;
      }
    }
  }
  cout << empty_nr << " " << max_score << endl;

  return 0;
}
Problem p00026 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
  int size, x, y, coord[20][20] = {0}, noink = 0, max = 0;

  while (scanf("%d,%d,%d", &x, &y, &size) != EOF) {
    x += 5;
    y += 5;
    coord[x][y]++;
    coord[x - 1][y]++;
    coord[x + 1][y]++;
    coord[x][y - 1]++;
    coord[x][y + 1]++;
    if (size >= 2) {
      coord[x - 1][y - 1]++;
      coord[x - 1][y + 1]++;
      coord[x + 1][y - 1]++;
      coord[x + 1][y + 1]++;
      if (size == 3) {
        coord[x - 2][y]++;
        coord[x + 2][y]++;
        coord[x][y - 2]++;
        coord[x][y + 2]++;
      }
    }
  }

  for (int i = 5; i < 15; i++) {
    for (int j = 5; j < 15; j++) {
      if (coord[i][j] == 0)
        noink++;
      if (coord[i][j] > max)
        max = coord[i][j];
    }
  }
  cout << noink << endl;
  cout << max << endl;
  return (0);
}

Error: WA

Fixed submission:

#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
  int size, x, y, coord[10][10], noink, max;

  while (scanf("%d,%d,%d", &x, &y, &size) != EOF) {
    coord[x][y]++;
    coord[x - 1][y]++;
    coord[x + 1][y]++;
    coord[x][y - 1]++;
    coord[x][y + 1]++;
    if (size >= 2) {
      coord[x - 1][y - 1]++;
      coord[x - 1][y + 1]++;
      coord[x + 1][y - 1]++;
      coord[x + 1][y + 1]++;
      if (size == 3) {
        coord[x - 2][y]++;
        coord[x + 2][y]++;
        coord[x][y - 2]++;
        coord[x][y + 2]++;
      }
    }
  }

  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      if (coord[i][j] == 0)
        noink++;
      if (coord[i][j] > max)
        max = coord[i][j];
    }
  }
  cout << noink << endl;
  cout << max << endl;
  return (0);
}
Problem p00026 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <stdio.h>
using namespace std;

int paper[10][10] = {0};

void small_ink(int x, int y) {
  paper[y][x]++;
  if (x + 1 < 10)
    paper[y][x + 1]++;
  if (x - 1 >= 0)
    paper[y][x - 1]++;
  if (y + 1 < 10)
    paper[y + 1][x]++;
  if (y - 1 >= 0)
    paper[y - 1][x]++;
}
void midium_ink(int x, int y) {
  for (int i = -1; i < 2; i++) {
    for (int j = -1; j < 2; j++) {
      if (y + i >= 0 && y + i < 10 && x + j >= 0 && x + j < 10)
        paper[y + i][x + j]++;
    }
  }
}
void big_ink(int x, int y) {
  for (int i = -1; i < 2; i++) {
    for (int j = -1; j < 2; j++) {
      if (y + i >= 0 && y + i < 10 && x + j >= 0 && x + j < 10)
        paper[y + i][x + j]++;
    }
  }
  for (int i = -1; i < 2; i = i + 2) {
    if (y + i * 2 >= 0 && y + i * 2 < 10)
      paper[y + i * 2][x]++;
  }
  for (int i = -1; i < 2; i = i + 2) {
    if (x + i * 2 >= 0 && x + i * 2 < 10)
      paper[y][x + i * 2]++;
  }
}

int main() {
  int x, y, s;
  int white = 0;
  int darkest = 0;
  while (scanf("%d,%d,%d", &x, &y, &s) != EOF) {
    if (s == 1)
      small_ink(x, y);
    else if (s == 2)
      midium_ink(x, y);
    else if (s == 3)
      big_ink(x, y);
  }
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      if (paper[i][j] == 0)
        white++;
      if (paper[i][j] > darkest)
        darkest = paper[i][j];
    }
  }
  cout << white << endl << darkest << endl;
}


Error: TLE

Fixed submission:

#include <iostream>
#include <stdio.h>
using namespace std;

int paper[10][10] = {0};

void small_ink(int x, int y) {
  paper[y][x]++;
  if (x + 1 < 10)
    paper[y][x + 1];
  if (x - 1 >= 0)
    paper[y][x - 1];
  if (y + 1 < 10)
    paper[y + 1][x];
  if (y - 1 >= 0)
    paper[y - 1][x];
}
void midium_ink(int x, int y) {
  for (int i = -1; i < 2; i++) {
    for (int j = -1; i < 2; j++) {
      if (y + i >= 0 && y + i < 10 && x + j >= 0 && x + j < 10)
        paper[y + i][x + j]++;
    }
  }
}
void big_ink(int x, int y) {
  for (int i = -1; i < 2; i++) {
    for (int j = -1; i < 2; j++) {
      if (y + i >= 0 && y + i < 10 && x + j >= 0 && x + j < 10)
        paper[y + i][x + j]++;
    }
  }
  for (int i = -1; i < 2; i = i + 2) {
    for (int j = -1; j < 2; j = j + 2) {
      if (y + i * 2 >= 0 && y + i * 2 < 10 && x + j * 2 >= 0 && x + j * 2 < 10)
        paper[y + i * 2][x + j * 2]++;
    }
  }
}

int main() {
  int x, y, s;
  int white = 0;
  int darkest = 0;
  while (scanf("%d,%d,%d", &x, &y, &s) != EOF) {
    if (s == 1)
      small_ink(x, y);
    else if (s == 2)
      midium_ink(x, y);
    else if (s == 3)
      big_ink(x, y);
  }
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      if (paper[i][j] == 0)
        white++;
      if (paper[i][j] > darkest)
        darkest = paper[i][j];
    }
  }
  cout << white << endl << darkest << endl;
}
Problem p00026 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int cnt[10][10];
int sx[] = {-1, 0, 0, 0, 1}, mx[] = {-1, -1, -1, 0, 0, 0, 1, 1, 1},
    lx[] = {-2, -1, -1, -1, 0, 0, 0, 0, 0, 1, 1, 1, 2};
int sy[] = {0, 1, 0, -1, 0}, my[] = {1, 0, -1, 1, 0, -1, 1, 0, -1},
    ly[] = {0, 1, 0, -1, 2, 1, 0, -1, -2, 1, 0, -1, 0};
bool isInside(int y, int x) {
  if (y < 0 || 10 <= y)
    return false;
  if (x < 0 || 10 <= x)
    return false;
  return true;
}
int main() {
  memset(cnt, 0, sizeof(cnt));
  int x, y, s;
  while (scanf("%d,%d,%d", &x, &y, &s) != EOF) {
    switch (s) {
    case 1:
      for (int i = 0; i < 5; i++) {
        if (isInside(y + sy[i], x + sx[i]))
          cnt[y + sy[i]][x + sx[i]]++;
      }
      break;
    case 2:
      for (int i = 0; i < 9; i++) {
        if (isInside(y + my[i], x + mx[i]))
          cnt[y + my[i]][x + mx[i]]++;
      }
      break;
    case 3:
      for (int i = 0; i < 13; i++) {
        if (isInside(y + ly[i], x + lx[i]))
          cnt[y + ly[i]][x + lx[i]]++;
      }
      break;
    case -1:
      goto end;
    }
  }
end:;
  int big = 0, blank = 0;
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      if (cnt[i][j] == 0)
        blank++;
      big = max(big, cnt[i][j]);
    }
  }
  cout << blank << endl;
  cout << big << endl;
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int cnt[10][10];
int sx[] = {-1, 0, 0, 0, 1}, mx[] = {-1, -1, -1, 0, 0, 0, 1, 1, 1},
    lx[] = {-2, -1, -1, -1, 0, 0, 0, 0, 0, 1, 1, 1, 2};
int sy[] = {0, 1, 0, -1, 0}, my[] = {1, 0, -1, 1, 0, -1, 1, 0, -1},
    ly[] = {0, 1, 0, -1, 2, 1, 0, -1, -2, 1, 0, -1, 0};
int main() {
  memset(cnt, 0, sizeof(cnt));
  int x, y, s;
  while (scanf("%d,%d,%d", &x, &y, &s) != EOF) {
    switch (s) {
    case 1:
      for (int i = 0; i < 5; i++) {
        cnt[y + sy[i]][x + sx[i]]++;
      }
      break;
    case 2:
      for (int i = 0; i < 9; i++) {
        cnt[y + my[i]][x + mx[i]]++;
      }
      break;
    case 3:
      for (int i = 0; i < 13; i++) {
        cnt[y + ly[i]][x + lx[i]]++;
      }
      break;
    case -1:
      goto end;
    }
  }
end:;
  int big = 0, blank = 0;
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      if (cnt[i][j] == 0)
        blank++;
      big = max(big, cnt[i][j]);
    }
  }
  cout << blank << endl;
  cout << big << endl;
  return 0;
}
Problem p00026 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
#include <iostream>

int paper[10][10] = {};

void drop(int x, int y) {
  if (x >= 0 && y >= 0 && x <= 9 && y <= 9) {
    ++paper[x][y];
  }
}

void ink(int x, int y, int s) {
  switch (s) {
  case 3:
    drop(x + 2, y);
    drop(x - 2, y);
    drop(x, y + 2);
    drop(x, y - 2);
  case 2:
    drop(x + 1, y + 1);
    drop(x - 1, y + 1);
    drop(x - 1, y - 1);
    drop(x + 1, y - 1);
  case 1:
    drop(x, y);
    drop(x + 1, y);
    drop(x - 1, y);
    drop(x, y + 1);
    drop(x, y - 1);
  }
}

int main() {
  int x, y, s;

  // drop(9,9);

  /*for(int i=0;i<10;i++){
    for(int j=0;j<10;j++){
      std::cout << paper[i][j] << std::endl;
    }
  }*/

  while (std::scanf(" %d,%d,%d", &x, &y, &s) + 1) {
    // std::cout << x << y << s;
    ink(x, y, s);
  }

  int spase = 0, max = 0;

  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      if (paper[i][j] == 0) {
        ++spase;
      }
      if (paper[i][j] > max) {
        max = paper[i][j];
      }
    }
  }

  std::cout << spase << std::endl;
  std::cout << max << std::endl;
}

Error: TLE

Fixed submission:

#include <cstdio>
#include <iostream>

int paper[10][10] = {};

void drop(int x, int y) {
  if (x >= 0 && y >= 0 && x <= 9 && y <= 9) {
    ++paper[x][y];
  }
}

void ink(int x, int y, int s) {
  switch (s) {
  case 3:
    drop(x + 2, y);
    drop(x - 2, y);
    drop(x, y + 2);
    drop(x, y - 2);
  case 2:
    drop(x + 1, y + 1);
    drop(x - 1, y + 1);
    drop(x - 1, y - 1);
    drop(x + 1, y - 1);
  case 1:
    drop(x, y);
    drop(x + 1, y);
    drop(x - 1, y);
    drop(x, y + 1);
    drop(x, y - 1);
  }
}

int main() {
  int x, y, s;

  // drop(9,9);

  /*for(int i=0;i<10;i++){
    for(int j=0;j<10;j++){
      std::cout << paper[i][j] << std::endl;
    }
  }*/

  while (std::scanf(" %d,%d,%d", &x, &y, &s)) {
    // std::cout << x << y << s;
    ink(x, y, s);
  }

  int spase = 0, max = 0;

  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      if (paper[i][j] == 0) {
        ++spase;
      }
      if (paper[i][j] > max) {
        max = paper[i][j];
      }
    }
  }

  std::cout << spase << std::endl;
  std::cout << max << std::endl;
}
Problem p00026 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;

int main() {
  vector<vector<int>> field(14, vector<int>(14, 0));
  int x, y, s;
  while (scanf("%d,%d,%d", &x, &y, &s) != EOF) {
    x += 2;
    y += 2;
    for (int i = -2; i <= 2; i++) {
      for (int j = -2; j <= 2; j++) {
        if (s == 1 && abs(i) + abs(j) <= 1) {
          field[x + i][y + j]++;
        }
        if (s == 2 && abs(i) <= 1 && abs(j) <= 1) {
          field[x + i][y + j]++;
        }
        if (s == 3 && abs(i) + abs(j) <= 2) {
          field[x + i][y + j]++;
        }
      }
    }
  }

  int white = 0;
  int deep = 0;
  for (int i = 2; i <= 11; i++) {
    for (int j = 2; j <= 11; j++) {
      deep = max(deep, field[i][j]);
      if (field[i][j] == 0)
        white++;
    }
  }
  cout << white << endl << deep << endl;
  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;

int main() {
  vector<vector<int>> field(12, vector<int>(12, 0));
  int x, y, s;
  while (scanf("%d,%d,%d", &x, &y, &s) != EOF) {
    x++;
    y++;
    for (int i = -2; i <= 2; i++) {
      for (int j = -2; j <= 2; j++) {
        if (s == 1 && abs(i) + abs(j) <= 1) {
          field[x + i][y + j]++;
        }
        if (s == 2 && abs(i) <= 1 && abs(j) <= 1) {
          field[x + i][y + j]++;
        }
        if (s == 3 && abs(i) + abs(j) <= 2) {
          field[x + i][y + j]++;
        }
      }
    }
  }

  int white = 0;
  int deep = 0;
  for (int i = 1; i <= 10; i++) {
    for (int j = 1; j <= 10; j++) {
      deep = max(deep, field[i][j]);
      if (field[i][j] == 0)
        white++;
    }
  }
  cout << white << endl << deep << endl;
  return 0;
}
Problem p00026 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main(void) {

  int map[10][10], ink, x, y, max = 0, count = 0;
  int dx[] = {0, 0, -1, 1, -1, -1, 1, 1, 0, 0, -2, 2};
  int dy[] = {-1, 1, 0, 0, -1, 1, -1, 1, -2, 2, 0, 0};

  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      map[i][j] = 0;
    }
  }

  while (scanf("%d,%d,%d", &x, &y, &ink) != EOF) {
    map[y][x]++;
    for (int i = 0; i < ink * 4; i++) {
      int mx = x + dx[i];
      int my = y + dy[i];
      if (mx >= 0 && mx < 10 && my >= 0 && my < 10) {
        map[my][mx]++;
      }
    }
  }

  for (int y = 0; y < 10; y++) {
    for (int x = 0; x < 10; x++) {
      if (map[y][x] == 0) {
        count++;
      }
      if (map[y][x] > max) {
        max = map[y][x];
      }
    }
  }
  printf("%d\\n%d\\n", count, max);
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main(void) {

  int map[10][10], ink, x, y, max = 0, count = 0;
  int dx[] = {0, 0, -1, 1, -1, -1, 1, 1, 0, 0, -2, 2};
  int dy[] = {-1, 1, 0, 0, -1, 1, -1, 1, -2, 2, 0, 0};

  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      map[i][j] = 0;
    }
  }

  while (scanf("%d,%d,%d", &x, &y, &ink)) {
    map[y][x]++;
    for (int i = 0; i < ink * 4; i++) {
      int mx = x + dx[i];
      int my = y + dy[i];
      if (mx >= 0 && mx < 10 && my >= 0 && my <= 10) {
        map[my][mx]++;
      }
    }
  }

  for (int y = 0; y < 10; y++) {
    for (int x = 0; x < 10; x++) {
      if (map[y][x] == 0) {
        count++;
      }
      if (map[y][x] > max) {
        max = map[y][x];
      }
    }
  }
  printf("%d\\n%d", count, max);
}