Submission #1041490


Source Code Expand

#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int x, y;

int sign(int a) {
    return (a >= 0 ? 1 : -1);
}

int solve() {
    if (abs(x) <= abs(y)) {
        return abs(y) - abs(x) + (x >= 0 && y >= 0 ? 0 : (x <= 0 && y <= 0 ? 2 : 1));
    } else {
        return abs(x) - abs(y) + (x >= 0 && y >= 0 ? 2 : (x <= 0 && y <= 0 ? 0 : 1));
    }
}

void input() {
    cin >> x >> y;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << solve() << endl;
}

Submission Info

Submission Time
Task A - Simple Calculator
User assy
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1585 Byte
Status WA
Exec Time 3 ms
Memory 256 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 300
Status
AC × 3
AC × 12
WA × 2
Set Name Test Cases
Sample 0_00.txt, 0_01.txt, 0_02.txt
All 0_00.txt, 0_01.txt, 0_02.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt
Case Name Status Exec Time Memory
0_00.txt AC 2 ms 256 KB
0_01.txt AC 2 ms 256 KB
0_02.txt AC 2 ms 256 KB
1_00.txt AC 2 ms 256 KB
1_01.txt AC 2 ms 256 KB
1_02.txt WA 2 ms 256 KB
1_03.txt WA 2 ms 256 KB
1_04.txt AC 2 ms 256 KB
1_05.txt AC 2 ms 256 KB
1_06.txt AC 3 ms 256 KB
1_07.txt AC 2 ms 256 KB
1_08.txt AC 3 ms 256 KB
1_09.txt AC 2 ms 256 KB
1_10.txt AC 2 ms 256 KB