# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
915365 |
2024-01-23T18:46:34 Z |
vjudge1 |
Bajka (COCI20_bajka) |
C++17 |
|
1 ms |
348 KB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define ii pair<int,int>
#define F first
#define S second
#define endl '\n'
const int N = 105;
char a[N][N];
signed main(){
int n, m;
cin >> n >> m;
string fear, fav;
cin >> fear >> fav;
int pos = -1;
for(int i=0; i<n; ++i){
if(fear[i] == fav[0]){
pos = i;
break;
}
}
if(pos == -1){
cout << -1;
return 0;
}
int ans = 0;
for(int i=1; i<m; ++i){
char want = fav[i];
if(pos > 0 && fear[pos-1] == want){
pos--;
ans++;
continue;
}
if(pos+1 < n && fear[pos+1] == want){
pos++;
ans++;
continue;
}
cout << -1;
return 0;
}
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |