Submission #1041806


Source Code Expand

#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i,n) for(int i=0;i<(n);i++)
#define All(v) v.begin(),v.end()
#define Uniq(v) v.erase(unique(All(v)),v.end())
typedef pair<int, int> Pii; 
typedef pair<int, Pii> Pip;
typedef pair<string, int> Psi;
const int INF = (1<<30);
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};

int main()
{
  ll x, y;
  ll ans = 0;
  cin >> x >> y;
  if( x >= 0 ) { //x:+
    if( y >= 0 ) { //y:+
      if( x > y ) {
	x = -x;
	ans++;
	ans += y - x;
      } else { //x < y
	ans = y - x;
      }
    } else { //y:-
      if( x > -y ) {
	ans++;
	ans += x + y;
      } else {
	ans++;
	ans += (-y) - x; 
      } 
    }
  } else { //x:-
    if( y >= 0 ) { //y:+
      if( -x > y ) {
	ans = (-x) + y;
      } else {
	ans = x + y;
	ans++;
      }
    } else { //y:-
      if( x > y ) {
	ans += (-y) - (-x);
	ans += 2;
      } else {
	ans += (-x) - (-y);
      }
    }
  }

  cout << ans << endl;
}

Submission Info

Submission Time
Task A - Simple Calculator
User shot
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1079 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 3 ms 256 KB
1_01.txt AC 3 ms 256 KB
1_02.txt AC 3 ms 256 KB
1_03.txt AC 2 ms 256 KB
1_04.txt AC 2 ms 256 KB
1_05.txt WA 2 ms 256 KB
1_06.txt AC 2 ms 256 KB
1_07.txt AC 2 ms 256 KB
1_08.txt AC 2 ms 256 KB
1_09.txt WA 2 ms 256 KB
1_10.txt AC 2 ms 256 KB