답안 #282949

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
282949 2020-08-25T07:42:50 Z 송준혁(#5748) Lock Puzzle (innopolis2018_final_A) C++17
9 / 100
1 ms 384 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;

int N, cnt[30];
char S[2020], T[2020], B[2020];
vector<int> V;

void sft(int x){
	V.push_back(x);
	for (int i=1; i<=x; i++) B[N-x+i] = S[i];
	for (int i=1; i<=N-x; i++) B[i] = S[N-i+1];
	for (int i=1; i<=N; i++) S[i] = B[i];
}

int main(){
	scanf("%d %*d", &N);
	scanf("%s", S+1);
	scanf("%s", T+1);
	for (int i=1; i<=N; i++) cnt[S[i]-'a']++;
	for (int i=1; i<=N; i++){
		cnt[T[i]-'a']--;
		if (cnt[T[i]-'a'] < 0){
			puts("-1");
			return 0;
		}
	}
	int s=N/2, e=s;
	for (int i=1; i<=N; i++){
		if (T[s] == S[i]){
			sft(i), sft(0);
			break;
		}
	}
	for (int i=1; i<N; i++){
		int t;
		if (i%4 == 1 || i%4 == 0) t=s-1, s--;
		else t=e+1, e++;
		if (i&1){
			for (int j=i+1; j<=N; j++) if (T[t] == S[j]){ 
				sft(j-1), sft(N+i-j+1);
				break;
			}
		}
		else{
			for (int j=1; j<=N-i; j++) if (T[t] == S[j]){
				sft(j), sft(N-1);
				break;
			}
		}
	}
	for (int i=1; i<=N; i++) if (S[i] != T[i]){
		sft(0);
		break;
	}
	printf("%d\n", (int)V.size());
	for (int x : V) printf("%d ", N-x);
	printf("\n");
	return 0;
}

Compilation message

A.cpp: In function 'int main()':
A.cpp:18:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   18 |  scanf("%d %*d", &N);
      |  ~~~~~^~~~~~~~~~~~~~
A.cpp:19:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   19 |  scanf("%s", S+1);
      |  ~~~~~^~~~~~~~~~~
A.cpp:20:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   20 |  scanf("%s", T+1);
      |  ~~~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB [n = 1, m = 10000], OK, 0 operations
2 Correct 1 ms 288 KB [n = 2, m = 10000], OK, 2 operations
3 Correct 1 ms 376 KB [n = 8, m = 10000], OK, 17 operations
4 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 17 operations
5 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 17 operations
6 Correct 0 ms 256 KB [n = 8, m = 10000], OK: No solution
7 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 17 operations
8 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 17 operations
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB [n = 1, m = 10000], OK, 0 operations
2 Correct 1 ms 288 KB [n = 2, m = 10000], OK, 2 operations
3 Correct 1 ms 376 KB [n = 8, m = 10000], OK, 17 operations
4 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 17 operations
5 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 17 operations
6 Correct 0 ms 256 KB [n = 8, m = 10000], OK: No solution
7 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 17 operations
8 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 17 operations
9 Correct 1 ms 384 KB [n = 49, m = 10000], OK, 97 operations
10 Correct 1 ms 256 KB [n = 50, m = 10000], OK, 98 operations
11 Correct 0 ms 256 KB [n = 100, m = 10000], OK, 201 operations
12 Incorrect 1 ms 384 KB S is not equal after all operations: S = piwtzwppzvjlgveyodjusqgzskidhfrjimtkbggjydpkeycftnrxbfxqgaobbmptblizaklrdegapzbpzqewaghebhnvzsutoyo, T = oyotuszvnhbehgaweqzpbzpagedrlkazilbtpmbboagqxfbxrntfcyekpdyjggbktmijrfhdikszgqsujdoyevgljvzppwztwpi
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB [n = 1, m = 10000], OK, 0 operations
2 Correct 1 ms 288 KB [n = 2, m = 10000], OK, 2 operations
3 Correct 1 ms 376 KB [n = 8, m = 10000], OK, 17 operations
4 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 17 operations
5 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 17 operations
6 Correct 0 ms 256 KB [n = 8, m = 10000], OK: No solution
7 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 17 operations
8 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 17 operations
9 Correct 1 ms 384 KB [n = 49, m = 10000], OK, 97 operations
10 Correct 1 ms 256 KB [n = 50, m = 10000], OK, 98 operations
11 Correct 0 ms 256 KB [n = 100, m = 10000], OK, 201 operations
12 Incorrect 1 ms 384 KB S is not equal after all operations: S = piwtzwppzvjlgveyodjusqgzskidhfrjimtkbggjydpkeycftnrxbfxqgaobbmptblizaklrdegapzbpzqewaghebhnvzsutoyo, T = oyotuszvnhbehgaweqzpbzpagedrlkazilbtpmbboagqxfbxrntfcyekpdyjggbktmijrfhdikszgqsujdoyevgljvzppwztwpi
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB [n = 1, m = 10000], OK, 0 operations
2 Correct 1 ms 288 KB [n = 2, m = 10000], OK, 2 operations
3 Correct 1 ms 376 KB [n = 8, m = 10000], OK, 17 operations
4 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 17 operations
5 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 17 operations
6 Correct 0 ms 256 KB [n = 8, m = 10000], OK: No solution
7 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 17 operations
8 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 17 operations
9 Correct 1 ms 384 KB [n = 49, m = 10000], OK, 97 operations
10 Correct 1 ms 256 KB [n = 50, m = 10000], OK, 98 operations
11 Correct 0 ms 256 KB [n = 100, m = 10000], OK, 201 operations
12 Incorrect 1 ms 384 KB S is not equal after all operations: S = piwtzwppzvjlgveyodjusqgzskidhfrjimtkbggjydpkeycftnrxbfxqgaobbmptblizaklrdegapzbpzqewaghebhnvzsutoyo, T = oyotuszvnhbehgaweqzpbzpagedrlkazilbtpmbboagqxfbxrntfcyekpdyjggbktmijrfhdikszgqsujdoyevgljvzppwztwpi
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB [n = 1, m = 10000], OK, 0 operations
2 Correct 1 ms 288 KB [n = 2, m = 10000], OK, 2 operations
3 Correct 1 ms 376 KB [n = 8, m = 10000], OK, 17 operations
4 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 17 operations
5 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 17 operations
6 Correct 0 ms 256 KB [n = 8, m = 10000], OK: No solution
7 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 17 operations
8 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 17 operations
9 Correct 1 ms 384 KB [n = 49, m = 10000], OK, 97 operations
10 Correct 1 ms 256 KB [n = 50, m = 10000], OK, 98 operations
11 Correct 0 ms 256 KB [n = 100, m = 10000], OK, 201 operations
12 Incorrect 1 ms 384 KB S is not equal after all operations: S = piwtzwppzvjlgveyodjusqgzskidhfrjimtkbggjydpkeycftnrxbfxqgaobbmptblizaklrdegapzbpzqewaghebhnvzsutoyo, T = oyotuszvnhbehgaweqzpbzpagedrlkazilbtpmbboagqxfbxrntfcyekpdyjggbktmijrfhdikszgqsujdoyevgljvzppwztwpi
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB [n = 1, m = 10000], OK, 0 operations
2 Correct 1 ms 288 KB [n = 2, m = 10000], OK, 2 operations
3 Correct 1 ms 376 KB [n = 8, m = 10000], OK, 17 operations
4 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 17 operations
5 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 17 operations
6 Correct 0 ms 256 KB [n = 8, m = 10000], OK: No solution
7 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 17 operations
8 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 17 operations
9 Correct 1 ms 384 KB [n = 49, m = 10000], OK, 97 operations
10 Correct 1 ms 256 KB [n = 50, m = 10000], OK, 98 operations
11 Correct 0 ms 256 KB [n = 100, m = 10000], OK, 201 operations
12 Incorrect 1 ms 384 KB S is not equal after all operations: S = piwtzwppzvjlgveyodjusqgzskidhfrjimtkbggjydpkeycftnrxbfxqgaobbmptblizaklrdegapzbpzqewaghebhnvzsutoyo, T = oyotuszvnhbehgaweqzpbzpagedrlkazilbtpmbboagqxfbxrntfcyekpdyjggbktmijrfhdikszgqsujdoyevgljvzppwztwpi
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB [n = 1, m = 10000], OK, 0 operations
2 Correct 1 ms 288 KB [n = 2, m = 10000], OK, 2 operations
3 Correct 1 ms 376 KB [n = 8, m = 10000], OK, 17 operations
4 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 17 operations
5 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 17 operations
6 Correct 0 ms 256 KB [n = 8, m = 10000], OK: No solution
7 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 17 operations
8 Correct 1 ms 256 KB [n = 8, m = 10000], OK, 17 operations
9 Correct 1 ms 384 KB [n = 49, m = 10000], OK, 97 operations
10 Correct 1 ms 256 KB [n = 50, m = 10000], OK, 98 operations
11 Correct 0 ms 256 KB [n = 100, m = 10000], OK, 201 operations
12 Incorrect 1 ms 384 KB S is not equal after all operations: S = piwtzwppzvjlgveyodjusqgzskidhfrjimtkbggjydpkeycftnrxbfxqgaobbmptblizaklrdegapzbpzqewaghebhnvzsutoyo, T = oyotuszvnhbehgaweqzpbzpagedrlkazilbtpmbboagqxfbxrntfcyekpdyjggbktmijrfhdikszgqsujdoyevgljvzppwztwpi
13 Halted 0 ms 0 KB -