ソースコード 拡げる

Copy
```#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>

#define llint long long int
#define NUM 1000000007

int residual[100001][10] = {};
void prev_calc(){
for(int i=0; i<10; i++){
residual[1][i] = i;
for(int j=2; j<=100000; j++){
residual[j][i] = (residual[j-1][i]*10)%13;
}
}
}

int ctoi(char c){
return c - '0';
}

int main(void){

llint k, x, y;
std::cin >> k >> x >> y;

if((k%2 == 0) && ((x+y)%2 == 1)){
std::cout << -1 << std::endl;
return 0;
}

std::vector<std::pair<llint, llint> > steps;
llint nx = 0;
llint ny = 0;
while(true){
llint remain = k;
llint diffx = x-nx;
llint diffy = y-ny;
if(diffx == 0 and diffy <= 2*k) break;

llint mv_x_abs = std::min(remain, std::abs(diffx));
nx += diffx<0 ? -mv_x_abs : mv_x_abs;
remain -= mv_x_abs;

llint mv_y_abs = remain; //std::min(remain, std::abs(diffy));
ny += diffy<0 ? -mv_y_abs : mv_y_abs;

steps.push_back(std::make_pair(nx, ny));
diffy = y-ny;
}

if((y-ny) % 2 == 0){
llint diffy = y-ny;
llint half = diffy/2;
nx += k-std::abs(half);
ny += half;
steps.push_back(std::make_pair(nx, ny));
nx -= k-std::abs(half);
ny += half;
steps.push_back(std::make_pair(nx, ny));
}else{
llint diffy = y-ny;
llint targety;
if(diffy < 0){
targety = y+k;
}else{
targety = y-k;
}

llint half = (targety-ny)/2;
nx += k-std::abs(half);
ny += half;
steps.push_back(std::make_pair(nx, ny));
nx -= k-std::abs(half);
ny += half;
steps.push_back(std::make_pair(nx, ny));
steps.push_back(std::make_pair(nx, y));
}

std::cout << steps.size() << std::endl;
for(const auto& elem: steps){
std::cout << elem.first << " " << elem.second << std::endl;
}

return 0;
}
```

#### 提出情報

提出日時 2019-07-27 22:15:16+0900 E - Golf yanagi3150 C++14 (GCC 5.4.1) 0 1930 Byte WA 322 ms 5744 KB

#### ジャッジ結果

 AC × 3
 AC × 25 WA × 30
セット名 テストケース
Sample sample_01.txt, sample_02.txt, sample_03.txt
Subtask1 sample_01.txt, sample_02.txt, sample_03.txt, sub1_01.txt, sub1_02.txt, sub1_03.txt, sub1_04.txt, sub1_05.txt, sub1_06.txt, sub1_07.txt, sub1_08.txt, sub1_09.txt, sub1_10.txt, sub1_11.txt, sub1_12.txt, sub1_13.txt, sub1_14.txt, sub1_15.txt, sub1_16.txt, sub1_17.txt, sub1_18.txt, sub1_19.txt, sub1_20.txt, sub1_21.txt, sub1_22.txt, sub1_23.txt, sub1_24.txt, sub1_25.txt, sub1_26.txt, sub1_27.txt, sub1_28.txt, sub1_29.txt, sub1_30.txt, sub1_31.txt, sub1_32.txt, sub1_33.txt, sub1_34.txt, sub1_35.txt, sub1_36.txt, sub1_37.txt, sub1_38.txt, sub1_39.txt, sub1_40.txt, sub1_41.txt, sub1_42.txt, sub1_43.txt, sub1_44.txt, sub1_45.txt, sub1_46.txt, sub1_47.txt, sub1_48.txt, sub1_49.txt, sub1_50.txt, sub1_51.txt, sub1_52.txt
ケース名 結果 実行時間 メモリ
sample_01.txt AC 1 ms 256 KB
sample_02.txt AC 1 ms 256 KB
sample_03.txt AC 1 ms 256 KB
sub1_01.txt WA 1 ms 256 KB
sub1_02.txt WA 1 ms 256 KB
sub1_03.txt WA 1 ms 256 KB
sub1_04.txt WA 1 ms 256 KB
sub1_05.txt AC 1 ms 256 KB
sub1_06.txt WA 1 ms 256 KB
sub1_07.txt WA 1 ms 256 KB
sub1_08.txt WA 2 ms 256 KB
sub1_09.txt AC 1 ms 256 KB
sub1_10.txt WA 1 ms 256 KB
sub1_11.txt WA 1 ms 256 KB
sub1_12.txt AC 1 ms 256 KB
sub1_13.txt WA 1 ms 256 KB
sub1_14.txt AC 1 ms 256 KB
sub1_15.txt WA 1 ms 256 KB
sub1_16.txt AC 4 ms 256 KB
sub1_17.txt WA 1 ms 256 KB
sub1_18.txt WA 1 ms 256 KB
sub1_19.txt WA 1 ms 256 KB
sub1_20.txt AC 15 ms 640 KB
sub1_21.txt AC 1 ms 256 KB
sub1_22.txt AC 1 ms 256 KB
sub1_23.txt AC 1 ms 256 KB
sub1_24.txt AC 4 ms 384 KB
sub1_25.txt WA 1 ms 256 KB
sub1_26.txt AC 1 ms 256 KB
sub1_27.txt AC 1 ms 256 KB
sub1_28.txt WA 1 ms 256 KB
sub1_29.txt AC 1 ms 256 KB
sub1_30.txt WA 1 ms 256 KB
sub1_31.txt WA 1 ms 256 KB
sub1_32.txt AC 1 ms 256 KB
sub1_33.txt WA 1 ms 256 KB
sub1_34.txt AC 322 ms 5744 KB
sub1_35.txt WA 1 ms 256 KB
sub1_36.txt WA 1 ms 256 KB
sub1_37.txt WA 1 ms 256 KB
sub1_38.txt WA 1 ms 256 KB
sub1_39.txt WA 2 ms 256 KB
sub1_40.txt WA 1 ms 256 KB
sub1_41.txt WA 1 ms 256 KB
sub1_42.txt AC 1 ms 256 KB
sub1_43.txt AC 1 ms 256 KB
sub1_44.txt AC 1 ms 256 KB
sub1_45.txt AC 1 ms 256 KB
sub1_46.txt WA 2 ms 256 KB
sub1_47.txt AC 110 ms 2420 KB
sub1_48.txt WA 1 ms 256 KB
sub1_49.txt WA 1 ms 256 KB
sub1_50.txt AC 1 ms 256 KB
sub1_51.txt AC 109 ms 2420 KB
sub1_52.txt WA 1 ms 256 KB