alexjercan/bugnet huggingface dataset:
Problem p02272 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>

using namespace std;

const int MAX = 500000;
const int SENTINEL = 2000000000;

int L[MAX / 2 + 2], R[MAX / 2 + 2];
int cnt;

void merge(int A[], int n, int left, int mid, int right) {
  int n1 = mid - left;
  int n2 = right - mid;

  for (int i = 0; i < n1; i++) {
    L[i] = A[left + i];
  }

  for (int i = 0; i < n2; i++) {
    R[i] = A[mid + i];
  }

  L[n1] = R[n2] = SENTINEL;
  int i = 0, j = 0;

  for (int k = left; k < right; k++) {
    cnt++;
    if (L[i] <= R[j]) {
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}

void mergeSort(int A[], int n, int left, int right) {
  if (left + 1 < right) {
    int mid = (left + right) / 2;
    mergeSort(A, n, left, mid);
    mergeSort(A, n, mid, right);
    merge(A, n, left, mid, right);
  }
}

int main() {
  int A[MAX], n;
  cnt = 0;

  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> A[i];
  }

  mergeSort(A, n, 0, n);

  for (int i = 0; i < n; i++) {
    if (i) {
      cout << " ";
    }
    cout << A[i];
  }

  cout << endl;

  cout << cnt << endl;
}

Error: 0

Fixed submission:

#include <iostream>

using namespace std;

const int MAX = 50000;
const int SENTINEL = 2000000000;

int L[MAX / 2 + 2], R[MAX / 2 + 2];
int cnt;

void merge(int A[], int n, int left, int mid, int right) {
  int n1 = mid - left;
  int n2 = right - mid;

  for (int i = 0; i < n1; i++) {
    L[i] = A[left + i];
  }

  for (int i = 0; i < n2; i++) {
    R[i] = A[mid + i];
  }

  L[n1] = R[n2] = SENTINEL;
  int i = 0, j = 0;

  for (int k = left; k < right; k++) {
    cnt++;
    if (L[i] <= R[j]) {
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}

void mergeSort(int A[], int n, int left, int right) {
  if (left + 1 < right) {
    int mid = (left + right) / 2;
    mergeSort(A, n, left, mid);
    mergeSort(A, n, mid, right);
    merge(A, n, left, mid, right);
  }
}

int main() {
  int A[MAX], n;
  cnt = 0;

  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> A[i];
  }

  mergeSort(A, n, 0, n);

  for (int i = 0; i < n; i++) {
    if (i) {
      cout << " ";
    }
    cout << A[i];
  }

  cout << endl;

  cout << cnt << endl;
}
Problem p02272 (C++) — buggy submission, verdict: Runtime Error

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

int A[500000], S = 0;

int merge(int l, int m, int r) {
  int n1 = m - l, n2 = r - m, i, j;
  int L[n1 + 1], R[n2 + 1];
  for (i = 0; i < n1; i++)
    L[i] = A[i + l];
  for (i = 0; i < n2; i++)
    R[i] = A[i + m];
  i = j = 0;
  for (int k = 0; k < r - l; k++, S++) {
    if (j == n2 || (i < n1 && L[i] <= R[j]))
      A[k + l] = L[i++];
    else
      A[k + l] = R[j++];
  }
}

int mergeSort(int l, int r) {
  if (l + 1 < r) {
    int m = (l + r) / 2;
    mergeSort(l, m);
    mergeSort(m, r);
    merge(l, m, r);
  }
}

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    scanf("%d", &A[i]);
  mergeSort(0, n);
  for (int i = 0; i < n; i++) {
    if (i)
      printf(" ");
    printf("%d", A[i]);
  }
  printf("\\n%d\\n", S);

  return 0;
}

Error: 0

Fixed submission:

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

int A[50001], S = 0;

int merge(int l, int m, int r) {
  int n1 = m - l, n2 = r - m, i, j;
  int L[n1 + 1], R[n2 + 1];
  for (i = 0; i < n1; i++)
    L[i] = A[i + l];
  for (i = 0; i < n2; i++)
    R[i] = A[i + m];
  i = j = 0;
  for (int k = 0; k < r - l; k++, S++) {
    if (j == n2 || (i < n1 && L[i] <= R[j]))
      A[k + l] = L[i++];
    else
      A[k + l] = R[j++];
  }
}

int mergeSort(int l, int r) {
  if (l + 1 < r) {
    int m = (l + r) / 2;
    mergeSort(l, m);
    mergeSort(m, r);
    merge(l, m, r);
  }
}

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    scanf("%d", &A[i]);
  mergeSort(0, n);
  for (int i = 0; i < n; i++) {
    if (i)
      printf(" ");
    printf("%d", A[i]);
  }
  printf("\\n%d\\n", S);

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

#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <queue>
#include <stack>
#include <vector>
using namespace std;

struct cdnt {
  double x;
  double y;
};
int n;
cdnt koch(cdnt p, cdnt q, int n) {
  cdnt pp;
  pp.x = (p.x * 2 + q.x) / 3;
  pp.y = (p.y * 2 + q.y) / 3;
  cdnt qq;
  qq.x = (p.x + q.x * 2) / 3;
  qq.y = (p.y + q.y * 2) / 3;
  double vx = (q.x - p.x) / 3;
  double vy = (q.y - p.y) / 3;
  cdnt rr;
  rr.x = pp.x + vx / 2 - sqrt(3) * vy / 2;
  rr.y = pp.y + sqrt(3) * vx / 2 + vy / 2;
  if (n == 0) {
    cout << p.x << " " << p.y << endl
         << pp.x << " " << pp.y << endl
         << rr.x << " " << rr.y << endl
         << qq.x << " " << qq.y << endl;
  } else {
    koch(p, pp, n - 1);
    koch(pp, rr, n - 1);
    koch(rr, qq, n - 1);
    koch(qq, q, n - 1);
  }
}

int main() {
  cin >> n;
  n--;
  cdnt p;
  p.x = 0;
  p.y = 0;
  cdnt q;
  q.x = 100;
  q.y = 0;
  if (n + 1)
    koch(p, q, n);
  else
    cout << "0 0" << endl;
  cout << "100 0" << endl;
  return 0;
}

Error: WA

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <queue>
#include <stack>
#include <vector>
using namespace std;

struct cdnt {
  double x;
  double y;
};
int n;
cdnt koch(cdnt p, cdnt q) {
  cdnt pp;
  pp.x = (p.x * 2 + q.x) / 3;
  pp.y = (p.y * 2 + q.y) / 3;
  cdnt qq;
  qq.x = (p.x + q.x * 2) / 3;
  qq.y = (p.y + q.y * 2) / 3;
  double vx = (q.x - p.x) / 3;
  double vy = (q.y - p.y) / 3;
  cdnt rr;
  rr.x = pp.x + vx / 2 - sqrt(3) * vy / 2;
  rr.y = pp.y + sqrt(3) * vx / 2 + vy / 2;
  if (n == 0) {
    cout << p.x << " " << p.y << endl
         << pp.x << " " << pp.y << endl
         << rr.x << " " << rr.y << endl
         << qq.x << " " << qq.y << endl;
  } else {
    n--;
    koch(p, pp);
    koch(pp, rr);
    koch(rr, qq);
    koch(qq, q);
  }
}

int main() {
  cin >> n;
  n--;
  cdnt p;
  p.x = 0;
  p.y = 0;
  cdnt q;
  q.x = 100;
  q.y = 0;
  if (n)
    koch(p, q);
  else
    cout << "0 0" << endl;
  cout << "100.00000000 0.00000000" << endl;
  return 0;
}
Problem p02273 (C++) — buggy submission, verdict: Runtime Error

#include <climits>
#include <cmath>
#include <iostream>
#include <list>   //???????????????????????????
#include <vector> //????????¢??????????????????
using namespace std;

struct Ten {
  double X;
  double Y;
};

void solve(list<Ten>::iterator P1, list<Ten>::iterator P2, list<Ten> &list1,
           int n) {
  if (n == 0) {
    return;
  }
  Ten s;
  Ten u;
  Ten t;
  Ten v;

  v.X = (P2->X - P1->X) / 3;
  v.Y = (P2->Y - P1->Y) / 3;
  s.X = P1->X + v.X;
  s.Y = P1->Y + v.Y;
  u.X = s.X + (v.X * cos(60 * M_PI / 180) - v.Y * sin(60 * M_PI / 180));
  u.Y = s.Y + (v.X * sin(60 * M_PI / 180) + v.Y * cos(60 * M_PI / 180));
  t.X = P2->X - v.X;
  t.Y = P2->Y - v.Y;

  list<Ten>::iterator itr_t = list1.insert(P2, t);
  list<Ten>::iterator itr_u = list1.insert(itr_t, u);
  list<Ten>::iterator itr_s = list1.insert(itr_u, s);

  n--;

  solve(P1, itr_s, list1, n);
  solve(itr_s, itr_u, list1, n);
  solve(itr_u, itr_t, list1, n);
  solve(itr_t, P2, list1, n);
}

int main(void) {
  int n;

  cin >> n;
  list<Ten> list1;

  Ten siten;
  siten.X = 0;
  siten.Y = 0;
  Ten syuten;
  syuten.X = 100;
  syuten.Y = 0;

  list1.push_back(siten);
  list1.push_back(syuten);

  solve(list1.begin(), --list1.end(), list1, n);

  for (list<Ten>::iterator i = list1.begin(); i != list1.end(); i++) {

    cout << (*i).X << " " << (*i).Y << endl;
  }

  return 0;
}

Error: WA

Fixed submission:

#include <climits>
#include <cmath>
#include <iostream>
#include <list>   //???????????????????????????
#include <vector> //????????¢??????????????????
using namespace std;

struct Ten {
  double X;
  double Y;
};

void solve(list<Ten>::iterator P1, list<Ten>::iterator P2, list<Ten> &list1,
           int n) {
  Ten s;
  Ten u;
  Ten t;
  Ten v;
  v.X = (P2->X - P1->X) / 3;
  v.Y = (P2->Y - P1->Y) / 3;
  s.X = P1->X + v.X;
  s.Y = P1->Y + v.Y;
  u.X = s.X + (v.X * cos(60 * M_PI / 180) - v.Y * sin(60 * M_PI / 180));
  u.Y = s.Y + (v.X * sin(60 * M_PI / 180) + v.Y * cos(60 * M_PI / 180));
  t.X = P2->X - v.X;
  t.Y = P2->Y - v.Y;

  list<Ten>::iterator itr_t = list1.insert(P2, t);
  list<Ten>::iterator itr_u = list1.insert(itr_t, u);
  list<Ten>::iterator itr_s = list1.insert(itr_u, s);

  n--;
  if (n != 0) {

    solve(P1, itr_s, list1, n);
    solve(itr_s, itr_u, list1, n);
    solve(itr_u, itr_t, list1, n);
    solve(itr_t, P2, list1, n);
  }
}

int main(void) {
  int n;

  cin >> n;
  list<Ten> list1;

  Ten siten;
  siten.X = 0;
  siten.Y = 0;
  Ten syuten;
  syuten.X = 100;
  syuten.Y = 0;

  list1.push_back(siten);
  list1.push_back(syuten);

  solve(list1.begin(), --list1.end(), list1, n);

  for (list<Ten>::iterator i = list1.begin(); i != list1.end(); i++) {

    cout << (*i).X << " " << (*i).Y << endl;
  }

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

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

struct P {
  double x, y;
  P() { x = 0.0, y = 0.0; }
  P(double x, double y) : x(x), y(y) {}
};
P operator+(const P &p1, const P &p2) { return P(p1.x + p2.x, p1.y + p2.y); }
P operator-(const P &p1, const P &p2) { return P(p1.x - p2.x, p1.y - p2.y); }
P operator*(double k, const P &p) { return P(k * p.x, k * p.y); }
P operator*(const P &p, double k) { return k * p; }

//       p5
//       /\\
// p1___/ \\___p2
//    p3  p4
void KochCurve(P p1, P p2, int n) {
  if (n == 0)
    return;

  P p3 = 1.0 / 3.0 * (p2 - p1) + p1;
  P p4 = 2.0 / 3.0 * (p2 - p1) + p1;
  P tmp = p4 - p3;
  P p5;

  double theta = M_PI / 3.0;
  p5.x = cos(theta) * tmp.x - sin(theta) * tmp.y + p3.x;
  p5.y = sin(theta) * tmp.x + cos(theta) * tmp.y + p3.y;

  KochCurve(p1, p3, n - 1);
  printf("%.8f %.8f\\n", p3.x, p3.y);
  KochCurve(p3, p5, n - 1);
  printf("%.8f %.8f\\n", p5.x, p5.y);
  KochCurve(p5, p4, n - 1);
  printf("%.8f %.8f\\n", p4.x, p4.y);
  KochCurve(p4, p2, n - 1);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n;
  cin >> n;

  printf("%.8f %.8f\\n", 0.0, 0.0);
  KochCurve(P(0.0, 0.0), P(100.0, 0), n);
  printf("%.8f %.8f\\n", 100.0, 0.0);

  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

struct P {
  double x, y;
  P() { x = 0.0, y = 0.0; }
  P(double x, double y) : x(x), y(y) {}
};
P operator+(const P &p1, const P &p2) { return P(p1.x + p2.x, p1.y + p2.y); }
P operator-(const P &p1, const P &p2) { return P(p1.x - p2.x, p1.y - p2.y); }
P operator*(double k, const P &p) { return P(k * p.x, k * p.y); }
P operator*(const P &p, double k) { return k * p; }

//       p5
//       /\\
// p1___/ \\___p2
//    p3  p4
void KochCurve(P p1, P p2, int n) {
  P p3 = 1.0 / 3.0 * (p2 - p1);
  P p4 = 2.0 / 3.0 * (p2 - p1);
  P tmp = p4 - p3;
  P p5;

  double theta = M_PI / 3.0;
  p5.x = cos(theta) * tmp.x - sin(theta) * tmp.y + p3.x;
  p5.y = sin(theta) * tmp.x + sin(theta) * tmp.y + p3.y;

  if (n == 1) {
    printf("%.8f %.8f\\n", p1.x, p1.y);
    printf("%.8f %.8f\\n", p3.x, p3.y);
    printf("%.8f %.8f\\n", p5.x, p5.y);
    printf("%.8f %.8f\\n", p4.x, p4.y);
    printf("%.8f %.8f\\n", p2.x, p2.y);
  } else {
    KochCurve(p1, p3, n - 1);
    KochCurve(p3, p5, n - 1);
    KochCurve(p5, p4, n - 1);
    KochCurve(p4, p2, n - 1);
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n;

  while (cin >> n) {
    KochCurve(P(0.0, 0.0), P(100.0, 0), n);
  }

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

#include "iomanip"
#include "iostream"
#include "math.h"

using namespace std;

static const double rad60 = 60.0 * 3.141592 / 180.0;

struct Pos {
  double x, y;
};

void solve(int n, int d, Pos start, Pos end) {

  Pos p[5];

  p[0].x = start.x;
  p[1].x = (end.x + start.x * 2) / 3;
  p[3].x = (end.x * 2 + start.x) / 3;
  p[4].x = end.x;

  p[0].y = start.y;
  p[1].y = (end.y + start.y * 2) / 3;
  p[3].y = (end.y * 2 + start.y) / 3;
  p[4].y = end.y;

  p[2].x =
      (p[3].x - p[1].x) * cos(rad60) - (p[3].y - p[1].y) * sin(rad60) + p[1].x;
  p[2].y =
      (p[3].x - p[1].x) * sin(rad60) + (p[3].y - p[1].y) * cos(rad60) + p[1].y;

  if (n == d + 1) {
    for (int i = 0; i < 4; i++) {
      cout << fixed << setprecision(8) << p[i].x << " " << fixed
           << setprecision(8) << p[i].y << endl;
    }
  } else {
    for (int i = 0; i < 4; i++) {
      solve(n, d + 1, p[i], p[i + 1]);
    }
  }
}

int main() {

  int n;
  cin >> n;

  Pos s, e;

  s.x = 0;
  s.y = 0;
  e.x = 100;
  e.y = 0;
  if (n == 0) {
    cout << fixed << setprecision(8) << s.x << " " << fixed << setprecision(8)
         << s.y << endl;
    cout << fixed << setprecision(8) << e.x << " " << fixed << setprecision(8)
         << e.y << endl;

  } else {
    solve(n, 0, s, e);

    cout << fixed << setprecision(8) << e.x << " " << fixed << setprecision(8)
         << e.y << endl;
  }
  return 0;
}

Error: WA

Fixed submission:

#include "iomanip"
#include "iostream"
#include "math.h"

using namespace std;

static const double rad60 = 60.0 * 3.141592 / 180.0;

struct Pos {
  double x, y;
};

void solve(int n, int d, Pos start, Pos end) {

  Pos p[5];

  p[0].x = start.x;
  p[1].x = (end.x - start.x) / 3;
  p[3].x = (end.x - start.x) / 3 * 2;
  p[4].x = end.x;

  p[0].y = start.y;
  p[1].y = (end.y - start.y) / 3;
  p[3].y = (end.y - start.y) / 3 * 2;
  p[4].y = end.y;

  p[2].x =
      (p[3].x - p[1].x) * cos(rad60) - (p[3].y - p[1].y) * sin(rad60) + p[1].x;
  p[2].y =
      (p[3].x - p[1].x) * sin(rad60) + (p[3].y - p[1].y) * cos(rad60) + p[1].y;

  if (n == d + 1) {
    for (int i = 0; i < 4; i++) {
      cout << fixed << setprecision(5) << p[i].x << " " << fixed
           << setprecision(5) << p[i].y << endl;
    }
  } else {
    for (int i = 0; i < 4; i++) {
      solve(n, d + 1, p[i], p[i + 1]);
    }
  }
}

int main() {

  int n;
  cin >> n;

  Pos s, e;

  s.x = 0;
  s.y = 0;
  e.x = 100;
  e.y = 0;

  solve(n, 0, s, e);

  cout << fixed << setprecision(5) << e.x << " " << fixed << setprecision(5)
       << e.y << endl;

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

#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;
void make_fractal(int n, double a, double b, double x, double y) {
  double c = (2 * a + x) / 3;
  double d = (2 * b + y) / 3;
  double e = (a + 2 * x) / 3;
  double f = (b + 2 * y) / 3;
  // 回転
  double th = M_PI * 60.0 / 180.0;
  double neox = (e - c) * cos(th) - (f - d) * sin(th) + c;
  double neoy = (e - c) * sin(th) + (f - d) * cos(th) + d;
  // 頂点の配列
  double newx[] = {a, c, neox, e, x};
  double newy[] = {b, d, neoy, f, y};

  if (n == 0) {
    printf("%.8f %.8f\\n", x, y);
    return;
  }
  if (n == 1) {
    for (int i = 1; i < 5; i++) {
      printf("%.8f %.8f\\n", newx[i], newy[i]);
    }
    return;
  }
  for (int i = 0; i < 4; i++) {
    make_fractal(n - 1, newx[i], newy[i], newx[i + 1], newy[i + 1]);
  }
}

int main() {
  int n;
  cin >> n;
  printf("%.8f %.8f\\n", 0.0, 0.0);
  make_fractal(n, 0.0, 0.0, 100.0, 0.0);
}
// ACできない。斜め直線に対する回転がうまくいかなかった。


Error: WA

Fixed submission:

#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;
void make_fractal(int n, int dep, double a, double b, double x, double y) {
  double c = (2 * a + x) / 3;
  double d = (2 * b + y) / 3;
  double e = (a + 2 * x) / 3;
  double f = (b + 2 * y) / 3;
  // 回転
  double neox = (1 / 2.0) * (e - c) - (sqrt(3.0) / 2) * (f - d) + c;
  double neoy = (sqrt(3.0) / 2) * (e - c) + (1 / 2.0) * (y - d) + d;
  // 頂点の配列
  double newx[] = {a, c, neox, e, x};
  double newy[] = {b, d, neoy, f, y};

  if (n == 1) {
    for (int i = 0; i < 5; i++) {
      printf("%f %f\\n", newx[i], newy[i]);
    }
    return;
  }
  for (int i = 0; i < dep; i++) {
    make_fractal(n - 1, 4 * dep, newx[i], newy[i], newx[i + 1], newy[i + 1]);
  }
}

int main() {
  int n;
  cin >> n;
  make_fractal(n, 4, 0.0, 0.0, 100.0, 0.0);
}
Problem p02273 (C++) — buggy submission, verdict: Runtime Error

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cstdio>
#include <math.h>
using namespace std;
const double th = M_PI * 60 / 180;
struct P {
  double x, y;
};
void makeKoch(P a, P b, int de) {
  if (de == 0)
    return;
  P c, d, e;
  c.x = (a.x * 2 + b.x) / 3;
  c.y = (a.y * 2 + b.y) / 3;
  d.x = (a.x + b.x * 2) / 3;
  d.y = (a.y + b.y * 2) / 3;
  e.x = c.x + (d.x - c.x) * cos(th) - (d.y - c.y) * sin(th);
  e.y = c.y + (d.x - c.x) * sin(th) + (d.y - c.y) * cos(th);
  makeKoch(a, c, de - 1);
  printf("%.8f %.8f\\n", c.x, c.y);
  makeKoch(c, e, de - 1);
  printf("%.8f %.8f\\n", e.x, e.y);
  makeKoch(e, d, de - 1);
  printf("%.8f %.8f\\n", d.x, d.y);
  makeKoch(d, b, de - 1);
}
int main() {
  P p0, p1;
  p0.x = 0;
  p0.y = 0;
  p1.x = 100;
  p1.y = 0;
  int n;
  scanf("%d", &n);
  printf("%.8f %.8f\\n", p0.x, p0.y);
  makeKoch(p0, p1, n);
  printf("%.8f %.8f\\n", p1.x, p1.y);
  return 0;
}

Error: -11

Fixed submission:

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cstdio>
#include <math.h>
using namespace std;
const int th = M_PI * 60 / 180;
struct P {
  double x, y;
};
void makeKoch(P a, P b, int de) {
  if (de == 0)
    return;
  P c, d, e;
  c.x = (a.x) * 2 + (b.x) / 3;
  c.y = (a.y) * 2 + (b.y) / 3;
  d.x = (a.x) + (b.x) * 2 / 3;
  d.y = (a.y) + (b.y) * 2 / 3;
  e.x = c.x + (d.x - c.x) * cos(th) - (d.y - c.y) * sin(th);
  e.y = c.y + (d.x - c.x) * sin(th) + (d.y - c.y) * cos(th);
  makeKoch(a, c, de - 1);
  printf("%.8f &.8f\\n", c.x, c.y);
  makeKoch(c, e, de - 1);
  printf("%.8f &.8f\\n", e.x, e.y);
  makeKoch(e, d, de - 1);
  printf("%.8f &.8f\\n", d.x, d.y);
  makeKoch(d, b, de - 1);
}
int main() {
  P p0, p1;
  p0.x = 0;
  p0.y = 0;
  p1.x = 0;
  p1.y = 100;
  int n;
  scanf("%d", n);
  printf("%.8f &.8f\\n", p0.x, p0.y);
  makeKoch(p0, p1, n);
  printf("%.8f &.8f\\n", p1.x, p1.y);
  return 0;
}
Problem p02273 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <limits.h>
#include <queue>
#include <stack>
#include <string.h>
#include <string>
#include <vector>
#define maxn 10000000
#define pi acos(-1)
#define ll long long
using namespace std;
struct node {
  double x;
  double y;
};
void solve(int n, node a, node b) {
  if (n == 0)
    return;
  node t, s, u;
  double th = M_PI * 60.0 / 180.0; // 将单位从度变为弧度；

  s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
  s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
  t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
  t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
  u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x; /// 旋转矩阵；
  u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

  solve(n - 1, a, s);
  printf("%.8lf %.8lf\\n", s.x, s.y);
  solve(n - 1, s, u);
  printf("%.8lf %.8lf\\n", u.x, u.y);
  solve(n - 1, u, t);
  printf("%.8lf %.8lf\\n", t.x, t.y);
  solve(n - 1, t, b);
}
int main() {
  node a, b;
  int n;
  cin >> n;
  a.x = 0;
  a.y = 0;
  b.x = 100;
  b.y = 0;
  printf("%.8lf %.8lf\\n", a.x, a.y);
  //	cout<<a.x<<" "<<a.y<<endl;
  solve(n, a, b);
  printf("%.8lf %.8lf\\n", b.x, b.y);
  //	cout<<b.x<<" "<<b.y<<endl;
  return 0;
}


Error: -11

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <limits.h>
#include <queue>
#include <stack>
#include <string.h>
#include <string>
#include <vector>
#define maxn 10000000
#define pi acos(-1)
#define ll long long
using namespace std;
struct node {
  double x;
  double y;
};
void solve(int n, node a, node b) {
  node t, s, u;
  double th = pi * 60.0 / 180.0; // 将单位从度变为弧度；

  s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
  s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
  t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
  t.x = (1.0 * a.y + 2.0 * b.y) / 3.0;
  u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
  u.y = (t.x - s.x) * sin(th) - (t.y - s.y) * cos(th) + s.y;

  solve(n - 1, a, s);
  cout << s.x << " " << s.y << endl;
  solve(n - 1, s, u);
  cout << u.x << " " << u.y << endl;
  solve(n - 1, u, t);
  cout << t.x << " " << t.y << endl;
  solve(n - 1, t, b);
}
int main() {
  node a, b;
  int n;
  cin >> n;
  a.x = 0;
  a.y = 0;
  b.x = 100;
  b.y = 0;
  cout << a.x << " " << a.y << endl;
  solve(n, a, b);
  cout << b.x << " " << b.y << endl;
  return 0;
}
Problem p02273 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <math.h>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
// 常に心してかかれ
// 簡単なことを簡単にできるように練習する
// びっくりするくらいつまらないことで詰まってることも多い
int n; // 問題で設定された呼び出し階層の深さ
class dot {
public:
  double x;
  double y;

  dot(double X, double Y) {
    x = X;
    y = Y;
  }
};

void makeDots(dot A, dot B, int m) { // m:この関数の呼び出し元の呼び出し階層
  double tmp_x;
  double tmp_y;

  tmp_x = A.x + (B.x - A.x) / 3;
  tmp_y = A.y + (B.y - A.y) / 3;

  dot P(tmp_x, tmp_y);

  tmp_x = sqrt(3.0) * (B.x - A.x) - (B.y - A.y);
  tmp_y = (B.x - A.x) + sqrt(3.0) * (B.y - A.y);
  tmp_x = tmp_x / (2 * sqrt(3.0));
  tmp_y = tmp_y / (2 * sqrt(3.0));
  tmp_x += A.x;
  tmp_y += A.y;

  dot Q(tmp_x, tmp_y);

  tmp_x = A.x + 2 * (B.x - A.x) / 3;
  tmp_y = A.y + 2 * (B.y - A.y) / 3;

  dot R(tmp_x, tmp_y);

  m++;
  if (m == n) {
    cout << A.x << " " << A.y << endl;
    cout << P.x << " " << P.y << endl;
    cout << Q.x << " " << Q.y << endl;
    cout << R.x << " " << R.y << endl;
    return;
  }

  makeDots(A, P, m);
  makeDots(P, Q, m);
  makeDots(Q, R, m);
  makeDots(R, B, m);
}

int main() {
  dot A(0, 0);
  dot B(100, 0);

  cin >> n;

  if (n == 0) {
    cout << "0.00000000 0.00000000" << endl;
    cout << "100.00000000 0.00000000" << endl;
    return 0;
  }
  makeDots(A, B, 0);

  cout << 100 << " " << 0 << endl;
  return 0;
}

Error: WA

Fixed submission:

#include <iostream>
#include <math.h>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
// 常に心してかかれ
// 簡単なことを簡単にできるように練習する
// びっくりするくらいつまらないことで詰まってることも多い
int n; // 問題で設定された呼び出し階層の深さ
class dot {
public:
  double x;
  double y;

  dot(double X, double Y) {
    x = X;
    y = Y;
  }
};

void makeDots(dot A, dot B, int m) { // m:この関数の呼び出し元の呼び出し階層
  double tmp_x;
  double tmp_y;

  tmp_x = A.x + (B.x - A.x) / 3;
  tmp_y = A.y + (B.y - A.y) / 3;

  dot P(tmp_x, tmp_y);

  tmp_x = sqrt(3.0) * (B.x - A.x) - (B.y - A.y);
  tmp_y = (B.x - A.x) + sqrt(3.0) * (B.y - A.y);
  tmp_x = tmp_x / (2 * sqrt(3.0));
  tmp_y = tmp_y / (2 * sqrt(3.0));
  tmp_x += A.x;
  tmp_y += A.y;

  dot Q(tmp_x, tmp_y);

  tmp_x = A.x + 2 * (B.x - A.x) / 3;
  tmp_y = A.y + 2 * (B.y - A.y) / 3;

  dot R(tmp_x, tmp_y);

  m++;
  if (m == n) {
    cout << A.x << " " << A.y << endl;
    cout << P.x << " " << P.y << endl;
    cout << Q.x << " " << Q.y << endl;
    cout << R.x << " " << R.y << endl;
    return;
  }

  makeDots(A, P, m);
  makeDots(P, Q, m);
  makeDots(Q, R, m);
  makeDots(R, B, m);
}

int main() {
  dot A(0, 0);
  dot B(100, 0);

  cin >> n;

  if (n == 0) {
    cout << "0.00000000 0.00000000" << endl;
    cout << "100.00000000 0.00000000" << endl;
  }
  makeDots(A, B, 0);

  cout << 100 << " " << 0 << endl;
  return 0;
}