Submission #3296388


Source Code Expand

/**
 * File    : E.cpp
 * Author  : Kazune Takahashi
 * Created : 2018-9-29 21:23:01
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(19920725));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

// const int dx[4] = {1, 0, -1, 0};
// const int dy[4] = {0, 1, 0, -1};

// const int C = 1e6+10;
// const ll M = 1000000007;

int N;
string S;
int parent[100010];

void no()
{
  cout << -1 << endl;
  exit(0);
}

void yes()
{
  for (auto i = 0; i < N; i++)
  {
    if (parent[i] != -1)
    {
      cout << i + 1 << " " << parent[i] + 1 << endl;
    }
  }
  exit(0);
}

int main()
{
  cin >> S;
  N = S.size();
  if (S[N - 1] == '1')
  {
    no();
  }
  for (auto i = 0; i < N - 2; i++)
  {
    int j = N - 2 - i;
    if (S[i] != S[j])
    {
      no();
    }
  }
  if (S[0] == '0')
  {
    no();
  }
  int M = N / 2;
  int now = 0;
  for (auto i = 0; i < M; i++)
  {
    if (S[i] == '1')
    {
      parent[now] = i + 1;
      now = i + 1;
      parent[now] = -1;
    }
    else
    {
      parent[i + 1] = now;
    }
  }
  for (auto i = M; i < N - 1; i++)
  {
    parent[i + 1] = now;
  }
  yes();
}

Submission Info

Submission Time
Task E - Tr/ee
User kazunetakahashi
Language C++14 (GCC 5.4.1)
Score 700
Code Size 2020 Byte
Status AC
Exec Time 175 ms
Memory 2048 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 700 / 700
Status
AC × 3
AC × 48
Set Name Test Cases
Sample sample1_1111.txt, sample2_1110.txt, sample3_1010.txt
All 00-0.txt, 000.txt, 11-1.txt, 110.txt, bin.txt, bins.txt, fib.txt, one_0.txt, one_1.txt, one_2.txt, one_3.txt, rndNO1.txt, rndNO_0.txt, rndNO_1.txt, rndNO_2.txt, rndNO_3.txt, rndNO_4.txt, rndNO_5.txt, rndNOeven.txt, rndNOn.txt, rndNOodd.txt, rndYESeven_0.txt, rndYESeven_1.txt, rndYESeven_2.txt, rndYESeven_3.txt, rndYESeven_4.txt, rndYESeven_5.txt, rndYESeven_6.txt, rndYESeven_7.txt, rndYESeven_8.txt, rndYESeven_9.txt, rndYESodd_0.txt, rndYESodd_1.txt, rndYESodd_2.txt, rndYESodd_3.txt, rndYESodd_4.txt, rndYESodd_5.txt, rndYESodd_6.txt, rndYESodd_7.txt, rndYESodd_8.txt, rndYESodd_9.txt, sample1_1111.txt, sample2_1110.txt, sample3_1010.txt, star_0.txt, star_1.txt, star_2.txt, star_3.txt
Case Name Status Exec Time Memory
00-0.txt AC 4 ms 512 KB
000.txt AC 1 ms 256 KB
11-1.txt AC 4 ms 512 KB
110.txt AC 1 ms 256 KB
bin.txt AC 112 ms 1408 KB
bins.txt AC 1 ms 256 KB
fib.txt AC 161 ms 1920 KB
one_0.txt AC 166 ms 2048 KB
one_1.txt AC 165 ms 2048 KB
one_2.txt AC 165 ms 2048 KB
one_3.txt AC 167 ms 2048 KB
rndNO1.txt AC 4 ms 512 KB
rndNO_0.txt AC 1 ms 256 KB
rndNO_1.txt AC 1 ms 256 KB
rndNO_2.txt AC 1 ms 256 KB
rndNO_3.txt AC 1 ms 256 KB
rndNO_4.txt AC 1 ms 256 KB
rndNO_5.txt AC 1 ms 256 KB
rndNOeven.txt AC 3 ms 384 KB
rndNOn.txt AC 4 ms 512 KB
rndNOodd.txt AC 4 ms 512 KB
rndYESeven_0.txt AC 2 ms 256 KB
rndYESeven_1.txt AC 3 ms 256 KB
rndYESeven_2.txt AC 6 ms 256 KB
rndYESeven_3.txt AC 1 ms 256 KB
rndYESeven_4.txt AC 12 ms 384 KB
rndYESeven_5.txt AC 51 ms 768 KB
rndYESeven_6.txt AC 1 ms 256 KB
rndYESeven_7.txt AC 2 ms 256 KB
rndYESeven_8.txt AC 1 ms 256 KB
rndYESeven_9.txt AC 2 ms 256 KB
rndYESodd_0.txt AC 1 ms 256 KB
rndYESodd_1.txt AC 59 ms 896 KB
rndYESodd_2.txt AC 4 ms 256 KB
rndYESodd_3.txt AC 1 ms 256 KB
rndYESodd_4.txt AC 1 ms 256 KB
rndYESodd_5.txt AC 1 ms 256 KB
rndYESodd_6.txt AC 3 ms 256 KB
rndYESodd_7.txt AC 22 ms 384 KB
rndYESodd_8.txt AC 2 ms 256 KB
rndYESodd_9.txt AC 1 ms 256 KB
sample1_1111.txt AC 1 ms 256 KB
sample2_1110.txt AC 1 ms 256 KB
sample3_1010.txt AC 1 ms 256 KB
star_0.txt AC 162 ms 1664 KB
star_1.txt AC 175 ms 1664 KB
star_2.txt AC 162 ms 1664 KB
star_3.txt AC 164 ms 1792 KB