Submission #826221


Source Code Expand

Copy
#include<bits/stdc++.h>

using namespace std;

int main()
{
  int N, L, A[100000];

  cin >> N >> L;
  for(int i = 0; i < N; i++) {
    cin >> A[i];
  }

  for(int pos = 0; pos < N; pos++) {
    if(pos >= 1 && A[pos - 1] + A[pos] >= L) {
      vector< int > step;
      step.push_back(pos - 1);
      for(int i = pos - 2; i >= 0; i--)
        step.push_back(i);
      for(int i = pos; i < N - 1; i++)
        step.push_back(i);
      reverse(step.begin(), step.end());

      cout << "Possible" << endl;
      for(int k : step) {
        cout << k + 1 << endl;
      }
      exit(0);
    } else if(pos + 1 < N && A[pos] + A[pos + 1] >= L) {
      vector< int > step;
      step.push_back(pos);
      for(int i = pos - 1; i >= 0; i--)
        step.push_back(i);
      for(int i = pos + 1; i < N - 1; i++)
        step.push_back(i);
      reverse(step.begin(), step.end());

      cout << "Possible" << endl;
      for(int k : step) {
        cout << k + 1 << endl;
      }
      exit(0);
    }
  }
  cout << "Impossible" << endl;

}

Submission Info

Submission Time
Task C - Knot Puzzle
User ei13333
Language C++14 (GCC 5.4.1)
Score 500
Code Size 1079 Byte
Status
Exec Time 794 ms
Memory 1784 KB

Judge Result

Set Name Score / Max Score Test Cases
Sample 0 / 0 0_00.txt, 0_01.txt, 0_02.txt
All 500 / 500 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, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt, 1_20.txt, 1_21.txt, 1_22.txt, 1_23.txt, 1_24.txt, 1_25.txt, 1_26.txt, 1_27.txt, 1_28.txt, 1_29.txt, 1_30.txt, 1_31.txt
Case Name Status Exec Time Memory
0_00.txt 4 ms 256 KB
0_01.txt 4 ms 256 KB
0_02.txt 4 ms 256 KB
1_00.txt 4 ms 256 KB
1_01.txt 4 ms 256 KB
1_02.txt 758 ms 1784 KB
1_03.txt 32 ms 640 KB
1_04.txt 612 ms 1784 KB
1_05.txt 31 ms 640 KB
1_06.txt 752 ms 1784 KB
1_07.txt 31 ms 640 KB
1_08.txt 612 ms 1656 KB
1_09.txt 32 ms 640 KB
1_10.txt 748 ms 1784 KB
1_11.txt 31 ms 640 KB
1_12.txt 654 ms 1784 KB
1_13.txt 80 ms 640 KB
1_14.txt 794 ms 1656 KB
1_15.txt 4 ms 256 KB
1_16.txt 4 ms 256 KB
1_17.txt 73 ms 640 KB
1_18.txt 756 ms 1656 KB
1_19.txt 74 ms 640 KB
1_20.txt 68 ms 640 KB
1_21.txt 671 ms 1656 KB
1_22.txt 720 ms 1656 KB
1_23.txt 70 ms 640 KB
1_24.txt 588 ms 1656 KB
1_25.txt 72 ms 640 KB
1_26.txt 740 ms 1656 KB
1_27.txt 638 ms 1656 KB
1_28.txt 767 ms 1656 KB
1_29.txt 598 ms 1656 KB
1_30.txt 630 ms 1656 KB
1_31.txt 721 ms 1656 KB