Submission #1041212
Source Code Expand
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
typedef long long ll;
ll d[4][4];
ll inf=1e18;
ll a[4];
int main(){
ll x,y;
cin>>x>>y;
a[0]=x,a[1]=-x,a[2]=y,a[3]=-y;
rep(i,4) rep(j,4) d[i][j]=inf;
rep(i,4) d[i][i]=0;
rep(i,4) rep(j,4) if(i!=j){
if((i^1)==j) chmin(d[i][j],1LL);
if(a[i]<=a[j]) chmin(d[i][j],a[j]-a[i]);
}
rep(i,4) rep(j,4) rep(k,4) chmin(d[j][k],d[j][i]+d[i][k]);
cout<<d[0][2]<<endl;
}
Submission Info
Submission Time |
|
Task |
A - Simple Calculator |
User |
sigma425 |
Language |
C++14 (GCC 5.4.1) |
Score |
300 |
Code Size |
999 Byte |
Status |
AC |
Exec Time |
2 ms |
Memory |
384 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
300 / 300 |
Status |
|
|
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 |
AC |
2 ms |
256 KB |
1_03.txt |
AC |
2 ms |
256 KB |
1_04.txt |
AC |
2 ms |
384 KB |
1_05.txt |
AC |
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 |
384 KB |
1_09.txt |
AC |
2 ms |
256 KB |
1_10.txt |
AC |
2 ms |
256 KB |