Submission details
Task:Osajono
Sender:kallam
Submission time:2015-10-03 14:41:58 +0300
Language:C++
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#10.05 s1details
#20.05 s1details
#30.05 s1details
#40.05 s1details
#50.05 s1details
#60.06 s2details
#70.06 s2details
#80.07 s2details
#90.05 s2details
#100.06 s2details
#110.05 s3details
#120.05 s3details
#130.05 s3details
#140.06 s3details
#150.06 s3details

Code

#include <iostream>
#include <vector>
#include <algorithm>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;
using std::vector;

void swap(int& a, int& b) {
  int tmp = a;
  a = b;
  b = tmp;
}

int main () {
  int n;
  cin >> n;

  int table[2][n];
  int result[n];
  int swaptable[n];

  for (int i= 0; i < 2; ++i) {
    for (int j = 0; j < n; ++j) {
      cin >> table[i][j];
    }
  }

  for (int j = 0; j < n - 1; ++j) {
    result[j] = table[1][j+1];
  }
  result[n-1] = table[1][0];

  swaptable[0] = 0;
  int pos = 0;

  while (true) {
    while ((swaptable[pos] < n) && (
        result[swaptable[pos]] == table[0][pos] ||
        result[swaptable[pos]] == table[1][pos])) {
      ++swaptable[pos];
    }

    //cerr << pos << ": " << swaptable[pos] << endl;

    if (swaptable[pos] == n) {
      --pos;
      swap(result[pos], result[swaptable[pos]]); // revence swap
      swaptable[pos]++;
    } else {
      swap(result[pos], result[swaptable[pos]]);
      ++pos;
      if (pos == n) {
        break;
      }
      swaptable[pos] = pos;
    }
  }

  for (int j = 0; j < n; ++j) {
    cout << result[j] << " ";
  }
  cout << endl;

  return 0;
}

Test details

Test 1

Group: 1

Verdict:

input
BBBAABBBAAAABBAAAABAABAABBBBBB...

correct output
2554

user output
(empty)

Test 2

Group: 1

Verdict:

input
GDFVYWQCZAFGICSXOSWBZMGPDBSSVL...

correct output
299

user output
(empty)

Test 3

Group: 1

Verdict:

input
AAAAAAAAAAAAAAAAAAAAAAAAAZAAAA...

correct output
4314

user output
(empty)

Test 4

Group: 1

Verdict:

input
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

correct output
4231

user output
(empty)

Test 5

Group: 1

Verdict:

input
QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ...

correct output
5050

user output
(empty)

Test 6

Group: 2

Verdict:

input
BBABABBBABBAABBABBABAABAAABABA...

correct output
6253029

user output
(empty)

Test 7

Group: 2

Verdict:

input
RBKJMLDVQMKHYKCNDIVVKOMFUXTFMG...

correct output
485173

user output
(empty)

Test 8

Group: 2

Verdict:

input
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

correct output
12427725

user output
(empty)

Test 9

Group: 2

Verdict:

input
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

correct output
12467549

user output
(empty)

Test 10

Group: 2

Verdict:

input
QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ...

correct output
12502500

user output
(empty)

Test 11

Group: 3

Verdict:

input
BAAAAABABBABAABAABABABBBABBAAB...

correct output
2500051369

user output
(empty)

Test 12

Group: 3

Verdict:

input
ABBURXDRVXAYBPXXOQZNYHLWGUEEWR...

correct output
192407124

user output
(empty)

Test 13

Group: 3

Verdict:

input
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

correct output
4998050400

user output
(empty)

Test 14

Group: 3

Verdict:

input
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...

correct output
4998850144

user output
(empty)

Test 15

Group: 3

Verdict:

input
QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ...

correct output
5000050000

user output
(empty)