Submission #1819807
Source Code Expand
#include <cstdio> #include <cstdlib> #include <cstring> #include <cctype> #include <cmath> #include <algorithm> #define rep(i, a, b) for (int i = (a), _ = (b); i <= _; ++ i) #define per(i, a, b) for (int i = (a), _ = (b); i >= _; -- i) #define For(i, a, b) for (int i = (a), _ = (b); i < _; ++ i) #define ri rd<int> using namespace std; const int maxN = 1e6 + 7; template<class T> inline T rd() { bool f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = 0; T x = 0; for (; isdigit(c); c = getchar()) x = x * 10 + c - 48; return f ? x : -x; } inline void NIE() { puts("-1"); exit(0); } int n; char s[maxN], t[maxN]; char nw[maxN], col; int main() { n = ri(); scanf("%s%s", s+1, t+1); int j = n+1, res = 0; per (i, n, 1) { if (j <= i) s[i] = col; if (s[i] == t[i]) continue; if (j <= i) ++res; else if (j == n+1) ++res, j = i; if (j > i) j = i; for (; j && s[j] != t[i]; -- j); if (s[j] != t[i]) NIE(); col = t[i]; } printf("%d\n", res); return 0; }
Submission Info
Submission Time | |
---|---|
Task | F - Shik and Copying String |
User | acha |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1057 Byte |
Status | WA |
Exec Time | 13 ms |
Memory | 2176 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:31:25: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%s%s", s+1, t+1); ^
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 1500 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | example0.txt, example1.txt, example2.txt, example3.txt |
All | 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, 024.txt, 025.txt, 026.txt, 027.txt, 028.txt, 029.txt, 030.txt, 031.txt, 032.txt, 033.txt, 034.txt, 035.txt, 036.txt, 037.txt, 038.txt, 039.txt, 040.txt, 041.txt, 042.txt, 043.txt, 044.txt, 045.txt, 046.txt, 047.txt, 048.txt, 049.txt, 050.txt, 051.txt, 052.txt, 053.txt, 054.txt, 055.txt, 056.txt, 057.txt, 058.txt, example0.txt, example1.txt, example2.txt, example3.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
000.txt | AC | 1 ms | 128 KB |
001.txt | AC | 1 ms | 128 KB |
002.txt | AC | 1 ms | 128 KB |
003.txt | AC | 1 ms | 128 KB |
004.txt | AC | 1 ms | 128 KB |
005.txt | AC | 1 ms | 128 KB |
006.txt | AC | 1 ms | 128 KB |
007.txt | AC | 1 ms | 128 KB |
008.txt | AC | 1 ms | 128 KB |
009.txt | AC | 1 ms | 128 KB |
010.txt | WA | 1 ms | 128 KB |
011.txt | WA | 1 ms | 128 KB |
012.txt | WA | 1 ms | 128 KB |
013.txt | WA | 1 ms | 128 KB |
014.txt | WA | 1 ms | 128 KB |
015.txt | WA | 1 ms | 128 KB |
016.txt | WA | 1 ms | 128 KB |
017.txt | WA | 1 ms | 128 KB |
018.txt | WA | 1 ms | 128 KB |
019.txt | WA | 1 ms | 128 KB |
020.txt | WA | 1 ms | 128 KB |
021.txt | WA | 1 ms | 128 KB |
022.txt | WA | 1 ms | 128 KB |
023.txt | WA | 1 ms | 128 KB |
024.txt | WA | 1 ms | 128 KB |
025.txt | AC | 7 ms | 2176 KB |
026.txt | AC | 9 ms | 2176 KB |
027.txt | AC | 8 ms | 2176 KB |
028.txt | WA | 13 ms | 2176 KB |
029.txt | WA | 13 ms | 2176 KB |
030.txt | WA | 8 ms | 2176 KB |
031.txt | WA | 8 ms | 2176 KB |
032.txt | WA | 9 ms | 2176 KB |
033.txt | WA | 9 ms | 2176 KB |
034.txt | WA | 9 ms | 2176 KB |
035.txt | WA | 9 ms | 2176 KB |
036.txt | WA | 9 ms | 2176 KB |
037.txt | WA | 9 ms | 2176 KB |
038.txt | WA | 9 ms | 2176 KB |
039.txt | WA | 9 ms | 2176 KB |
040.txt | WA | 11 ms | 2176 KB |
041.txt | WA | 10 ms | 2176 KB |
042.txt | WA | 9 ms | 2176 KB |
043.txt | WA | 9 ms | 2176 KB |
044.txt | WA | 8 ms | 2176 KB |
045.txt | WA | 8 ms | 2176 KB |
046.txt | WA | 8 ms | 2176 KB |
047.txt | WA | 8 ms | 2176 KB |
048.txt | WA | 8 ms | 2176 KB |
049.txt | WA | 8 ms | 2176 KB |
050.txt | AC | 9 ms | 2176 KB |
051.txt | AC | 8 ms | 2176 KB |
052.txt | AC | 7 ms | 2048 KB |
053.txt | WA | 10 ms | 2176 KB |
054.txt | WA | 10 ms | 2176 KB |
055.txt | WA | 10 ms | 2176 KB |
056.txt | WA | 10 ms | 2176 KB |
057.txt | WA | 10 ms | 2048 KB |
058.txt | WA | 10 ms | 2176 KB |
example0.txt | AC | 1 ms | 128 KB |
example1.txt | AC | 1 ms | 128 KB |
example2.txt | AC | 1 ms | 128 KB |
example3.txt | AC | 1 ms | 128 KB |