QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#749674#8772. House Deconstructioncyj888TL 0ms0kbC++141.1kb2024-11-15 09:06:552024-11-15 09:06:55

Judging History

你现在查看的是最新测评结果

  • [2024-11-15 09:06:55]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Time Limit Exceeded

input:

6 2 4
1 P
2 H
3 P
4 H
5 H
6 H

output:


result: