結果

問題 No.1412 Super Ryuo
ユーザー gunmaneko
提出日時 2021-02-28 21:23:47
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 7,148 bytes
コンパイル時間 1,877 ms
コンパイル使用メモリ 178,792 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-02 22:03:28
合計ジャッジ時間 2,355 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include "bits/stdc++.h"
//#include <atcoder/all>
//using namespace atcoder;
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;
const long long INF = 1LL << 60;
long long fac[MAX], finv[MAX], inv[MAX];
//()
const int MAX_N = 10000000;
//
long long int n,dat[2*MAX_N - 1];
long long int bit[MAX_N+1];
//
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
//
long long int COM(long long int n,long long int k) {
if (n < k) return 0;
if (n < 0 || k < 0) return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/**/
long long int maxtime(long long int x, long long int y) {
return(x + y - 1) / y;
}
/**/
long long int lcm(long long int number1, long long int number2) {
long long int m = number1;
long long int n = number2;
if (number2 > number1) {
m = number2;
n = number1;
}
long long int s = -1;
while (s != 0) {
s = m % n;
m = n;
n = s;
}
return m;
}
/**/
long long int gcd(long long int number1, long long int number2) {
long long int m = number1;
long long int n = number2;
return m / lcm(m, n) * n;
}
/**/
long long int modinv(long long a, long long m) {
long long int b = m, u = 1, v = 0;
while (b) {
long long int t = a / b;
a -= t * b; swap(a, b);
u -= t * v; swap(u, v);
}
u %= m;
if (u < 0) u += m;
return u;
}
long long int mod(long long int val, long long int m) {
long long int res = val % m;
if (res < 0) res += m;
return res;
}
//
void init(long long int n_){
//
n = 1;
while(n < n_) {
n *= 2;
}
//INT_MAX
for(long long int i = 0; i < 2 * n - 1; i++){
//dat[i] = INT_MAX;
dat[i] = 0;
}
}
// k(0-indexed)a
void update(long long int k, long long int a){
//
k += n - 1;
dat[k] = a;
//
while(k > 0){
k = (k - 1) / 2;
dat[k] = max(dat[k * 2 + 1], dat[k * 2 + 2]);
}
}
// [a, b)
// 
//k, l, r[l, r)
// query(a, b, 0, 0, n)
int query(long long int a, long long int b,long long int k = 0,long long int l = 0,long long int r = n){
// [a, b)[l, r)INT_MAX
if (r <= a || b <= l){
return 0;
}
// [a, b)[l, r)
if (a <= l && r <= b){
return dat[k];
}else{
//2
long long int vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
long long int vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
return max(vl,vr);
}
}
//Union-Find 
long long int par[MAX_N]; //
long long int ranks[MAX_N]; //
//n
void initunion(long long int n){
for(long long int i = 0;i < n;i++){
par[i] = i;
ranks[i] = 0;
}
}
//
long long int find(long long int x){
if (par[x] == x){
return x;
}else{
return par[x] = find(par[x]);
}
}
//xy
void unite(long long int x, long long int y){
x = find(x);
y = find(y);
if(x == y){
return;
}
if(ranks[x] < ranks[y]){
par[x] = y;
}else{
par[y] = x;
if(ranks[x] == ranks[y]){
ranks[x]++;
}
}
}
//xy
bool same(long long int x,long long int y){
return find(x) == find(y);
}
//
// index
vector<long long int >meguru;
// index
bool isOK(long long int index, long long int key) {
if (meguru[index] >= key) return true;
else return false;
}
//
long long int binary_search(long long int key) {
long long int left = -1; //index = 0 -1
long long int right = (int)meguru.size(); // index = a.size()-1 a.size()
/* */
while (right - left > 1) {
long long int mid = left + (right - left) / 2;
if (isOK(mid, key)) right = mid;
else left = mid;
}
/* left right */
return right;
}
long long int modpow(long long int a, long long int n, long long int mod) {
long long int res = 1;
while (n > 0) {
if (n & 1) res = res * a % mod;
a = a * a % mod;
n >>= 1;
}
return res;
}
struct Edge {
long long int to;
long long int cost;
};
using Graph = vector<vector<Edge>>;
using P = pair<long long int ,long long int>;
/* dijkstra(G,s,dis)
G, s, dis
O(|E|log|V|)
dis
*/
void dijkstra(const Graph &G,long long int s, vector<long long int > &dis) {
long long int N = G.size();
dis.resize(N, INF);
priority_queue<P, vector<P>, greater<P>> pq; // ,
dis[s] = 0;
pq.emplace(dis[s], s);
while (!pq.empty()) {
P p = pq.top();
pq.pop();
long long int v = p.second;
if (dis[v] < p.first) { //
continue;
}
for (auto &e : G[v]) {
if (dis[e.to] > dis[v] + e.cost) { // priority_queue
dis[e.to] = dis[v] + e.cost;
pq.emplace(dis[e.to], e.to);
}
}
}
}
long long int sum (long long int i){
long long int s = 0;
while(i > 0){
s += bit[i];
i -= i & -i;
}
return s;
}
void add(long long int i, long long int x){
while(i <= n){
bit[i] += x;
i += i & -1;
}
}
int main(){
long long int a,b,c,d;
cin >> a >> b >> c >> d;
if(abs(a-c)+abs(b-d) <= 3){
cout << 1 << endl;
return 0;
}
if(a == c || b == d){
cout << 1 << endl;
return 0;
}
cout << 2 << endl;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0