Submission #59168491


Source Code Expand

Copy
// Monday left me broken
// Tuesday I was through with hopin'
// Wednesday my empty arms were open
// Thursday waiting for love, waiting for love
// Thank the stars it's Friday
// I'm burning like a fire gone wild on Saturday
// Guess I won't be coming to church on Sunday
// I'll be waiting for love
// Waiting for love to come around
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define MP make_pair
#define inf 0x3f3f3f3f
#define pi pair<long long int,long long int>
#define gcd(x,y) __gcd( x, y)
#define ALL(x) x.begin(),x.end()
#define pll pair<long long,long long>
#define debug(x) cerr<<#x<<':'<<x<<endl
 
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// Monday left me broken
// Tuesday I was through with hopin'
// Wednesday my empty arms were open
// Thursday waiting for love, waiting for love
// Thank the stars it's Friday
// I'm burning like a fire gone wild on Saturday
// Guess I won't be coming to church on Sunday
// I'll be waiting for love
// Waiting for love to come around
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define MP make_pair
#define inf 0x3f3f3f3f
#define pi pair<long long int,long long int>
#define gcd(x,y) __gcd( x, y)
#define ALL(x) x.begin(),x.end()
#define pll pair<long long,long long>
#define debug(x) cerr<<#x<<':'<<x<<endl
#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define lb lower_bound
#define ub upper_bound
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define INTMAX 2147483647
#define INT_MAX LONG_LONG_MAX
#define int long long
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset; //upper_bound and lower_bound swap functions in multi
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set_ll;
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset_ll;
mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
template<class K,class V> using ht = gp_hash_table<K,V,hash<K>,equal_to<K>,direct_mask_range_hashing<>,linear_probe_fn<>,hash_standard_resize_policy<hash_exponential_size_policy<>,hash_load_check_resize_trigger<>,true>>;
// scem unordered_map and unordered_set, to use umap use ht<ll,ll>, emplace doesnt exist so use .insert(), .reserve() is .resize(),  to declare uset is ht<ll,null_type>, all other operations are same as regular

void solve() {
    ll n, m, t1, t2; cin >> n >> m; ll ans = n*n;
    unordered_map<ll, unordered_set<ll>> gay;
    vector<pair<ll,ll>> valid_moves = {{2, -1}, {2, 1}, {-2, -1}, {-2, 1}, {1, -2}, {-1, -2}, {1, 2}, {-1, 2}}; 
    for (ll q = 0; q < m; q++) {
        cin >> t1 >> t2; t1--; t2--;
        if (gay[t1].find(t2) == gay[t1].end()) {
            gay[t1].insert(t2); ans--;
        }
        for (auto it: valid_moves) {
            ll ny = it.first + t1, nx = it.second + t2;
            if (ny >= n || nx < 0 || ny < 0 || nx >= n) continue;
            if (gay[ny].find(nx) == gay[ny].end()) {
                gay[ny].insert(nx); ans--;
            }
        }
    }
    cout << ans;
}

signed main() {
ios_base::sync_with_stdio(false);cin.tie(NULL);
  ll tc=1;
  //cin >> tc;
  for (ll q = 0; q < tc; q++) {solve();}
}

Submission Info

Submission Time
Task C - Avoid Knight Attack
User Jxsh28
Language C++ 17 (gcc 12.2)
Score 300
Code Size 3071 Byte
Status AC
Exec Time 663 ms
Memory 257944 KB

Compile Error

Main.cpp:34: warning: "INT_MAX" redefined
   34 | #define INT_MAX LONG_LONG_MAX
      | 
In file included from /usr/include/c++/12/climits:42,
                 from /usr/include/x86_64-linux-gnu/c++/12/bits/stdc++.h:39,
                 from Main.cpp:10:
/usr/lib/gcc/x86_64-linux-gnu/12/include/limits.h:120: note: this is the location of the previous definition
  120 | #define INT_MAX __INT_MAX__
      | 

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 35
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_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, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 01_random_23.txt, 01_random_24.txt, 01_random_25.txt, 01_random_26.txt, 01_random_27.txt, 01_random_28.txt, 01_random_29.txt, 01_random_30.txt, 01_random_31.txt, 01_random_32.txt, 01_random_33.txt, 01_random_34.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3476 KB
00_sample_01.txt AC 1 ms 3476 KB
00_sample_02.txt AC 1 ms 3444 KB
01_random_03.txt AC 100 ms 11784 KB
01_random_04.txt AC 257 ms 39328 KB
01_random_05.txt AC 547 ms 87156 KB
01_random_06.txt AC 478 ms 183620 KB
01_random_07.txt AC 663 ms 256832 KB
01_random_08.txt AC 628 ms 257944 KB
01_random_09.txt AC 25 ms 6748 KB
01_random_10.txt AC 153 ms 26848 KB
01_random_11.txt AC 220 ms 44416 KB
01_random_12.txt AC 28 ms 21148 KB
01_random_13.txt AC 407 ms 176136 KB
01_random_14.txt AC 52 ms 34368 KB
01_random_15.txt AC 1 ms 3480 KB
01_random_16.txt AC 1 ms 3460 KB
01_random_17.txt AC 1 ms 3488 KB
01_random_18.txt AC 1 ms 3604 KB
01_random_19.txt AC 1 ms 3460 KB
01_random_20.txt AC 1 ms 3472 KB
01_random_21.txt AC 1 ms 3488 KB
01_random_22.txt AC 1 ms 3548 KB
01_random_23.txt AC 99 ms 11776 KB
01_random_24.txt AC 221 ms 33560 KB
01_random_25.txt AC 312 ms 53900 KB
01_random_26.txt AC 345 ms 75956 KB
01_random_27.txt AC 385 ms 80000 KB
01_random_28.txt AC 376 ms 79828 KB
01_random_29.txt AC 2 ms 3832 KB
01_random_30.txt AC 26 ms 6728 KB
01_random_31.txt AC 186 ms 42548 KB
01_random_32.txt AC 8 ms 6852 KB
01_random_33.txt AC 1 ms 3604 KB
01_random_34.txt AC 122 ms 55912 KB


2025-03-05 (Wed)
12:18:06 +00:00