Submission #283693

# Submission time Handle Problem Language Result Execution time Memory
283693 2020-08-26T05:40:35 Z arnold518 Lock Puzzle (innopolis2018_final_A) C++14
0 / 100
0 ms 256 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 2000;

int N, M;
char S[MAXN+10];
char T[MAXN+10];

int cnt[30];

vector<int> V;
void f(int x)
{
	reverse(S+1, S+x+1);
	V.push_back(x);
	V.push_back(1);
}

int main()
{
	scanf("%d%d", &N, &M);
	scanf(" %s", S+1);
	scanf(" %s", T+1);

	for(int i=1; i<=N; i++) cnt[S[i]-'a']++, cnt[T[i]-'a']--;
	for(int i=0; i<26; i++) if(cnt[i]!=0) return !printf("-1\n");

	for(int i=N; i>=1; i--)
	{
		if(S[i]==T[i]) continue;
		int p;
		for(int j=1; j<i; j++) if(S[j]==T[i]) { p=j; break; }
		f(p);
		f(i);
	}
	printf("%d\n", V.size());
	for(auto it : V) printf("%d ", it);
}

Compilation message

A.cpp: In function 'int main()':
A.cpp:41:11: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wformat=]
   41 |  printf("%d\n", V.size());
      |          ~^     ~~~~~~~~
      |           |           |
      |           int         std::vector<int>::size_type {aka long unsigned int}
      |          %ld
A.cpp:26:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   26 |  scanf("%d%d", &N, &M);
      |  ~~~~~^~~~~~~~~~~~~~~~
A.cpp:27:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   27 |  scanf(" %s", S+1);
      |  ~~~~~^~~~~~~~~~~~
A.cpp:28:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   28 |  scanf(" %s", T+1);
      |  ~~~~~^~~~~~~~~~~~
A.cpp:38:4: warning: 'p' may be used uninitialized in this function [-Wmaybe-uninitialized]
   38 |   f(p);
      |   ~^~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB [n = 1, m = 10000], OK, 0 operations
2 Incorrect 0 ms 256 KB S is not equal after all operations: S = hd, T = dh
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB [n = 1, m = 10000], OK, 0 operations
2 Incorrect 0 ms 256 KB S is not equal after all operations: S = hd, T = dh
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB [n = 1, m = 10000], OK, 0 operations
2 Incorrect 0 ms 256 KB S is not equal after all operations: S = hd, T = dh
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB [n = 1, m = 10000], OK, 0 operations
2 Incorrect 0 ms 256 KB S is not equal after all operations: S = hd, T = dh
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB [n = 1, m = 10000], OK, 0 operations
2 Incorrect 0 ms 256 KB S is not equal after all operations: S = hd, T = dh
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB [n = 1, m = 10000], OK, 0 operations
2 Incorrect 0 ms 256 KB S is not equal after all operations: S = hd, T = dh
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB [n = 1, m = 10000], OK, 0 operations
2 Incorrect 0 ms 256 KB S is not equal after all operations: S = hd, T = dh
3 Halted 0 ms 0 KB -