# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
315735 | 2020-10-23T20:30:37 Z | DanerZein | Bajka (COCI20_bajka) | C++14 | 1 ms | 384 KB |
#include <bits/stdc++.h> using namespace std; int main(){ int n,m; cin>>n>>m; string x,y; cin>>x>>y; int id=-1; for(int i=0;i<x.size();i++){ if(x[i]==y[0]){ id=i; break; } } if(id==-1) {cout<<"-1\n"; return 0;} int j=1; bool sw=0; int res=0; while(true){ if(j==m) break; if(id+1<n && x[id+1]==y[j]){ id++; j++; } else if(id-1>=0 && x[id-1]==y[j]){ id--; j++; } else{ sw=1; break; } res++; } if(sw==1) cout<<"-1\n"; else cout<<res<<endl; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 0 ms | 256 KB | Output is correct |
4 | Correct | 0 ms | 256 KB | Output is correct |
5 | Correct | 0 ms | 256 KB | Output is correct |
6 | Correct | 1 ms | 256 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Incorrect | 0 ms | 384 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |