Submission #2405398
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define x first
#define y second
queue<pair<pp,int>> q;
int dx[6] = {1, 0, -1, -2, 2, 0};
int dy[6] = {1, -1, 0, -2, 0, 2};
set<pp> vis;
int main()
{
int a, b, c; read(a, b, c);
q.emplace(pp{b-a, c-a}, 0);
vis.emplace(b-a, c-a);
while(q.size()){
int a, b; tie(a, b) = q.front().x;
int d = q.front().y;
q.pop();
if(a==0 && b==0){
printf("%d\n", d);
return 0;
}
for(int dd=0; dd<6; ++dd){
int nx=a+dx[dd];
int ny=b+dy[dd];
if(vis.find(pp{nx, ny}) == vis.end()){
vis.insert(pp{nx, ny});
q.emplace(pp{nx, ny}, d+1);
}
}
}
return 0;
}
Submission Info
Submission Time |
|
Task |
C - Same Integers |
User |
Namnamseo |
Language |
C++14 (GCC 5.4.1) |
Score |
300 |
Code Size |
991 Byte |
Status |
AC |
Exec Time |
11 ms |
Memory |
1024 KB |
Compile Error
./Main.cpp: In function ‘void read(int&)’:
./Main.cpp:6:34: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
void read(int& x){ scanf("%d",&x); }
^
./Main.cpp: In function ‘void read(ll&)’:
./Main.cpp:7:35: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
void read(ll& x){ scanf("%lld",&x); }
^
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
300 / 300 |
Status |
|
|
Set Name |
Test Cases |
Sample |
s1.txt, s2.txt, s3.txt |
All |
01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, s1.txt, s2.txt, s3.txt |
Case Name |
Status |
Exec Time |
Memory |
01.txt |
AC |
1 ms |
256 KB |
02.txt |
AC |
2 ms |
384 KB |
03.txt |
AC |
2 ms |
256 KB |
04.txt |
AC |
2 ms |
384 KB |
05.txt |
AC |
1 ms |
256 KB |
06.txt |
AC |
11 ms |
1024 KB |
07.txt |
AC |
3 ms |
384 KB |
08.txt |
AC |
3 ms |
512 KB |
09.txt |
AC |
1 ms |
256 KB |
10.txt |
AC |
1 ms |
256 KB |
11.txt |
AC |
2 ms |
384 KB |
12.txt |
AC |
1 ms |
256 KB |
13.txt |
AC |
5 ms |
512 KB |
s1.txt |
AC |
1 ms |
256 KB |
s2.txt |
AC |
1 ms |
256 KB |
s3.txt |
AC |
3 ms |
384 KB |