Submission #71673503


Source Code Expand

/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Anurudh Peduri (codelegend)
 */

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = array<int, 2>;
using VI = vector<int>;

void prec() {}

struct Solver {
  set<PII> pts;

  bool place(int x, int y, bool insert = false) {
    for (int dx : {0, 1}) {
      for (int dy : {0, 1}) {
        const PII p{x + dx, y + dy};
        if (pts.count(p)) return false;
        if (insert) pts.insert(p);
      }
    }
    return true;
  }

  void solve(istream &cin, ostream &cout) {
    int n, m;
    cin >> n >> m;

    int ans = 0;
    while (m--) {
      int x, y;
      cin >> x >> y;
      if (place(x, y)) {
        place(x, y, true);
        ans++;
      }
    }
    cout << ans << '\n';
  }
};

//====== Submission Template; Ignore ========//
struct C2x2Placing {
  int case_num = 0;
  void solve(std::istream &in, std::ostream &out) {
#ifdef PRINT_CASE_NUMBERS
    case_num++;
    out << "Case #" << case_num << ": ";
#endif
    Solver().solve(in, out);
  }
};

int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  prec();
  C2x2Placing solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}

Submission Info

Submission Time
Task C - 2x2 Placing
User codelegend
Language C++23 (GCC 15.2.0)
Score 300
Code Size 1369 Byte
Status AC
Exec Time 524 ms
Memory 41156 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 36
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 02_random2_00.txt, 02_random2_01.txt, 02_random2_02.txt, 02_random2_03.txt, 02_random2_04.txt, 02_random2_05.txt, 02_random2_06.txt, 02_random2_07.txt, 02_random2_08.txt, 02_random2_09.txt, 02_random2_10.txt, 02_random2_11.txt, 02_random2_12.txt, 02_random2_13.txt, 02_random2_14.txt, 02_random2_15.txt, 03_handmade_00.txt, 03_handmade_01.txt, 03_handmade_02.txt, 03_handmade_03.txt, 03_handmade_04.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 2 ms 3448 KiB
00_sample_01.txt AC 1 ms 3588 KiB
00_sample_02.txt AC 1 ms 3600 KiB
01_random_00.txt AC 7 ms 3592 KiB
01_random_01.txt AC 11 ms 3580 KiB
01_random_02.txt AC 15 ms 3540 KiB
01_random_03.txt AC 31 ms 3716 KiB
01_random_04.txt AC 81 ms 11040 KiB
01_random_05.txt AC 53 ms 4676 KiB
01_random_06.txt AC 263 ms 24704 KiB
01_random_07.txt AC 503 ms 39444 KiB
01_random_08.txt AC 258 ms 22740 KiB
01_random_09.txt AC 524 ms 40824 KiB
01_random_10.txt AC 68 ms 11392 KiB
01_random_11.txt AC 435 ms 41156 KiB
02_random2_00.txt AC 422 ms 41092 KiB
02_random2_01.txt AC 426 ms 40960 KiB
02_random2_02.txt AC 422 ms 40796 KiB
02_random2_03.txt AC 420 ms 40412 KiB
02_random2_04.txt AC 411 ms 39936 KiB
02_random2_05.txt AC 411 ms 39412 KiB
02_random2_06.txt AC 405 ms 38688 KiB
02_random2_07.txt AC 390 ms 37900 KiB
02_random2_08.txt AC 367 ms 36880 KiB
02_random2_09.txt AC 359 ms 35328 KiB
02_random2_10.txt AC 329 ms 33036 KiB
02_random2_11.txt AC 307 ms 30280 KiB
02_random2_12.txt AC 259 ms 25924 KiB
02_random2_13.txt AC 208 ms 20436 KiB
02_random2_14.txt AC 129 ms 13056 KiB
02_random2_15.txt AC 34 ms 3844 KiB
03_handmade_00.txt AC 11 ms 3592 KiB
03_handmade_01.txt AC 142 ms 22380 KiB
03_handmade_02.txt AC 172 ms 22404 KiB
03_handmade_03.txt AC 142 ms 22404 KiB
03_handmade_04.txt AC 114 ms 16132 KiB