提出 #9407367


ソースコード 拡げる

#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
            ∧_∧
      ∧_∧  (´<_` )  Welcome to My Coding Space!
     ( ´_ゝ`) /  ⌒i     @hamayanhamayan0
    /   \     | |
    /   / ̄ ̄ ̄ ̄/  |
  __(__ニつ/     _/ .| .|____
     \/____/ (u ⊃
---------------------------------------------------------------------------------------------------*/














int N, P[8], Q[8];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	rep(i, 0, N) cin >> P[i];
	rep(i, 0, N) cin >> Q[i];
	
	vector<int> v;
	rep(i, 0, N) v.push_back(i + 1);
	int idx = 0, a = -1, b = -1;
	do {
		bool ok = true;
		rep(i, 0, N) if (v[i] != P[i]) ok = false;
		if (ok) a = idx;

		ok = true;
		rep(i, 0, N) if (v[i] != Q[i]) ok = false;
		if (ok) b = idx;

		idx++;
	} while (next_permutation(all(v)));

	int ans = abs(a - b);
	cout << ans << endl;
}





提出情報

提出日時
問題 C - Count Order
ユーザ hamayanhamayan
言語 C++14 (GCC 5.4.1)
得点 300
コード長 1856 Byte
結果 AC
実行時間 2 ms
メモリ 256 KiB

ジャッジ結果

セット名 All Sample
得点 / 配点 300 / 300 0 / 0
結果
AC × 13
AC × 3
セット名 テストケース
All sample_01.txt, sample_02.txt, sample_03.txt, testcase_0.txt, testcase_1.txt, testcase_2.txt, testcase_3.txt, testcase_4.txt, testcase_5.txt, testcase_6.txt, testcase_7.txt, testcase_8.txt, testcase_9.txt
Sample sample_01.txt, sample_02.txt, sample_03.txt
ケース名 結果 実行時間 メモリ
sample_01.txt AC 1 ms 256 KiB
sample_02.txt AC 2 ms 256 KiB
sample_03.txt AC 1 ms 256 KiB
testcase_0.txt AC 1 ms 256 KiB
testcase_1.txt AC 1 ms 256 KiB
testcase_2.txt AC 1 ms 256 KiB
testcase_3.txt AC 2 ms 256 KiB
testcase_4.txt AC 1 ms 256 KiB
testcase_5.txt AC 1 ms 256 KiB
testcase_6.txt AC 1 ms 256 KiB
testcase_7.txt AC 2 ms 256 KiB
testcase_8.txt AC 2 ms 256 KiB
testcase_9.txt AC 2 ms 256 KiB