CSES - Leirikisa 4 - Results
Submission details
Task:slom
Sender:Kuha
Submission time:2016-08-01 15:31:36 +0300
Language:C++
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED100
Test results
testverdicttime
#1ACCEPTED0.05 sdetails
#2ACCEPTED0.06 sdetails
#3ACCEPTED0.06 sdetails
#4ACCEPTED0.05 sdetails
#5ACCEPTED0.05 sdetails
#6ACCEPTED0.05 sdetails
#7ACCEPTED0.06 sdetails
#8ACCEPTED0.05 sdetails
#9ACCEPTED0.06 sdetails
#10ACCEPTED0.05 sdetails
#11ACCEPTED0.05 sdetails
#12ACCEPTED0.06 sdetails
#13ACCEPTED0.06 sdetails

Code

#include <bits/stdc++.h>
#define ll long long
#define INF 999999999
#define LINF 999999999999999999LL
#define N (1<<17)
#define M 1000000007

using namespace std;

int v[1001][32];

int main () {
  int n;
  string s;
  cin>>n>>s;
  string ans = s;
  int l = s.length();
  for (int i = 0; i < l; i++) {
    if (i % 2 == 0) {
      v[i][0] = i / 2;
    } else {
      v[i][0] = l - 1 - i / 2;
    }
  }
  cout<<endl;
  for (int i = 1; i < 32; i++) {
    for (int j = 0; j < l; j++) {
      v[j][i] = v[v[j][i - 1]][i - 1];
    }
  }
  
  for (int j = 0; j < l; j++) {
    int p = j;
    for (int i = 0; i < 32; i++) {
      if (n & (1<<i)) {
	p = v[p][i];
      }
    }
    ans[p] = s[j];
  }
  cout<<ans<<endl;
}

Test details

Test 1

Verdict: ACCEPTED

input
4
acefdb

correct output
abcdef

user output

abcdef

Test 2

Verdict: ACCEPTED

input
1000
aaaaaa

correct output
aaaaaa

user output

aaaaaa

Test 3

Verdict: ACCEPTED

input
11
srama

correct output
sarma

user output

sarma

Test 4

Verdict: ACCEPTED

input
10
tbqhcahaje

correct output
tqchjeaahb

user output

tqchjeaahb

Test 5

Verdict: ACCEPTED

input
50
mvkaysdrpqkahelvtxwd

correct output
myphtdvaravsqexwlkdk

user output

myphtdvaravsqexwlkdk

Test 6

Verdict: ACCEPTED

input
60
hfhnhgjyqegacpwcvieckehtayuqgi...

correct output
hhqcvkagqtccaynfgepieyiuhewgjh...

user output

hhqcvkagqtccaynfgepieyiuhewgjh

Test 7

Verdict: ACCEPTED

input
100
kqrminhwirfjvnliauxbnltmdxexqg...

correct output
kddjxfpoagwhrigjcifgqxwynfwckj...

user output

kddjxfpoagwhrigjcifgqxwynfwckj...

Test 8

Verdict: ACCEPTED

input
100
renxibkpvavjnopqftypofrtfbfkke...

correct output
rpmkvedndjakqcrybmuywbnqspjraq...

user output

rpmkvedndjakqcrybmuywbnqspjraq...

Test 9

Verdict: ACCEPTED

input
98765322
pjbsuxmdxyoxmlfokhmgpcnebqcpyx...

correct output
pgypycmdmnjkrlkcaqtrwyhdswtmne...

user output

pgypycmdmnjkrlkcaqtrwyhdswtmne...

Test 10

Verdict: ACCEPTED

input
33892018
bmrtldbdycikkknkifujppdldpqxee...

correct output
bwxqwwogalkjqrrarbqlrekfxoltkf...

user output

bwxqwwogalkjqrrarbqlrekfxoltkf...

Test 11

Verdict: ACCEPTED

input
839254838
xjvoqfnjtgcscdexvaccdetxxppgsl...

correct output
xvuocylqxrdedqcirbveydcculfmev...

user output

xvuocylqxrdedqcirbveydcculfmev...

Test 12

Verdict: ACCEPTED

input
1000000000
rsiufeylcjcvvyaxuknaxpjmelvugt...

correct output
rifyccvaunxjevgumtjieklaxggldh...

user output

rifyccvaunxjevgumtjieklaxggldh...

Test 13

Verdict: ACCEPTED

input
997997997
pintfuxuddywgihkulppiuhwdpofbc...

correct output
pasfapecysfwqommqhotrublrmbpdn...

user output

pasfapecysfwqommqhotrublrmbpdn...