結果
問題 | No.2018 X-Y-X |
ユーザー |
![]() |
提出日時 | 2022-07-23 00:10:04 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 509 bytes |
コンパイル時間 | 2,040 ms |
コンパイル使用メモリ | 192,344 KB |
最終ジャッジ日時 | 2025-01-30 13:09:56 |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 7 WA * 24 |
ソースコード
#define rep(i,n) for(int i=0;i<(int)(n);i++) #define ALL(v) v.begin(),v.end() typedef long long ll; #include<bits/stdc++.h> using namespace std; int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); int n; string s,t; cin>>n>>s>>t; if(s[0]!=t[0] || s[n-1]!=t[n-1]){ cout<<-1<<endl; return 0; } int cnt=0; bool b=false; rep(i,n){ if(s[i]!=t[i]) cnt++; if(i<n-2 && s[i]==s[i+2]) b=true; } if(b==false) cout<<-1<<endl; else cout<<cnt<<endl; return 0; }