QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#749674 | #8772. House Deconstruction | cyj888 | TL | 0ms | 0kb | C++14 | 1.1kb | 2024-11-15 09:06:55 | 2024-11-15 09:06:55 |
answer
#include <bits/stdc++.h>
//#define int long long
#define fi first
#define se second
#define pb push_back
#define ott(i, l, r) for (register int i = (l); i <= (r); i ++)
#define tto(i, l, r) for (register int i = (r); i >= (l); i --)
using namespace std;
typedef long long ll;
typedef long double ld;
int read () {
int x = 0; bool f = false; char c = getchar ();
while (!isdigit (c)) f |= (c == '-'), c = getchar ();
while (isdigit (c)) x = (x << 3) + (x << 1) + (c ^ 48), c = getchar ();
return f ? -x : x;
}
const int N = 2e5 + 110, mod = 1e9 + 7;
int n, m; bool fl;
int a[N << 1], b[N];
int main () {
n = read (), m = read (); ott (i, 1, n) a[i + n] = a[i] = read (); ott (i, 1, m) b[i] = read ();
ott (i, 1, n + n - m + 1) {
if (a[i] == b[1]) {
bool ok = true;
ott (j, 1, m) ok &= b[j] == a[i + j - 1];
fl |= ok;
}
}
reverse (a + 1, a + 1 + n + n);
ott (i, 1, n + n - m + 1) {
if (a[i] == b[1]) {
bool ok = true;
ott (j, 1, m) ok &= b[j] == a[i + j - 1];
fl |= ok;
}
}
printf ("%d\n", fl);
return 0;
}
詳細信息
Test #1:
score: 0
Time Limit Exceeded
input:
6 2 4 1 P 2 H 3 P 4 H 5 H 6 H