prompt string | response string |
|---|---|
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const double eps = 1e-6;
const int N = 2005, M = 205;
const int base = mod;
char a[N][M], b[M][N];
unsigned long long p[N];
unsigned long long ha[N][M], hb[M][N];
int n, m;
inline unsigned long long get_hash(unsigned long... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
int N, M;
string MA[2005], MB[205];
long long HA[2005], HB[2005];
bool chk(int r, int c) {
for (int i = 0; i <= M - 1; i++)
for (int j = 0; j <= M - 1; j++)
if (MA[r + i][j] != MB[i][c + j]) return false;
return true;
}
int main() {
ios::sync_with_stdio(fals... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
const int N = 2002;
int z[N];
void buildZArray(vector<int> &str) {
int l = 0, r = 0, sz = str.size();
for (int i = 1; i < sz; ++i) {
if (i > r) {
l = r = i;
while (r < sz && str[r - l] == str[r]) ++r;
z[i] = r - l, --r;
} else if (z[i - l] < r ... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
long long n, m;
long long base = 26;
char a[2001][201];
char b[201][2001];
long long hash1[2001];
long long hash2[201];
map<long long, long long> top_left;
signed main() {
cin >> n >> m;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
const int maxx = 600010;
const double pi = acos(-1.0);
const double eps = 1e-15;
map<pair<long long, long long>, int> h;
int t, n, m;
long long a1 = 0, a2 = 0, ans = 0, total = 0, s1 = 0, s2 = 0, cnt = 0, r1 = 0,
r2 = 0, p1 = 0, p2 = 0;
char c1[3111][3111], c2[311... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
const int N = 2000, M = 200;
char map1[N][M], map2[M][N];
int n, m;
map<string, int> list1, list2;
void set1(int r) {
string s;
for (int i = 0; i < m; i++)
for (int j = 0; j < m; j++) s.push_back(map1[r + i][j]);
list1[s] = r;
}
void set2(int c) {
string s;
fo... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | N, M = map(int, raw_input().split())
m1 = [raw_input() for _ in range(N)]
m2 = [raw_input() for _ in range(M)]
h1 = list(map(hash, m1))
# h1 = [h1[i:i + M] for i in range(N - M + 1)]
h2 = [[hash(x[i:i + M]) for x in m2] for i in range(N - M + 1)]
def cal():
for i in range(N - M + 1):
for j in range(N - M... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
const int N = 2005, M = 205, M1 = 1e9 + 7, M2 = 1e9 + 9;
char a[N][M], b[M][N];
int A[N], B[N];
int n, m;
int main() {
scanf("%d%d", &n, &m);
for (int i = 0; i < n; i++) {
scanf("%s", a[i]);
}
for (int i = 0; i < m; i++) {
scanf("%s", b[i]);
}
for (int i... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
const int N = 2000 + 5;
int n, m;
struct hash_table {
unsigned long long seed;
unsigned long long Hash[N], temp[N];
void Set(unsigned long long num) { seed = num; }
void work(char *s, int n) {
temp[0] = 1;
Hash[0] = 0;
for (int i = 1; i <= n; i++) temp[i... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
int mod_inv(long long x, int M) {
int t = M - 2, y = 1;
for (; t; t >>= 1) {
if (t & 1) y = y * x % M;
x = x * x % M;
}
return y;
}
struct rolling_hash {
int mod;
vector<vector<int>> a, b;
rolling_hash(vector<string> s, int _mod) {
mod = _mod;
... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 50;
const int oo = 1e9;
const int mod = 1e9 + 7;
string a[2001], b[201], f1[2001], f2[2001];
int main() {
int n, m;
cin >> n >> m;
for (int i = 0; i < n; i++) cin >> a[i];
for (int i = 0; i < m; i++) cin >> b[i];
for (int i = 0; i + m <= n; i++... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
const int MOD = 998244353;
const int maxn = 1010;
const int K = 11;
const int INF = 1e9 + 10;
const double eps = 1e-13;
const long long mo = 1000000000039ll, base = 9971;
const int N = 2005, M = 205;
map<long long, int> f;
int n, m;
char a[N][M];
char b[M][N];
int main() {
... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
string map1[n], map2[m];
int hash1[n], hash2[n];
for (int i = 0; i < n; i++) {
cin >> map1[i];
hash1[i] = 0;
for (int j = 0; j < m; j++) {
hash1[i] += pow(-1, j) * (map1[i][j] - 'a');
}
}
for (int i =... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
const double Pi = 3.14159265;
const int N = 3e3 + 5;
const unsigned long long base = 163;
const int INF = 0x3f3f3f3f;
using namespace std;
unsigned long long p[N], Ha[N][N], ha[N][N];
char s1[N];
unsigned long long get(int l, int r, unsigned long long *a) {
return a[r] - a[l - 1] * p[r - l + ... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | /*
* Created on 17.05.2019
*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/**
* @author Wolfgang Weck
*/
public class A01Medium {
public static void main(String[] args) {
try (BufferedReader r = new BufferedReader(new InputStreamReader(System.in))) {
final Str... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
mt19937 rnd(228);
const int M = 1791791791;
const int B = 239;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n, m;
cin >> n >> m;
vector<string> a(n), b(m);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
for (int i = 0; i < m; i++) {
cin >> b[i... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
int di[] = {0, 0, 1, -1, 1, 1, -1, -1};
int dj[] = {1, -1, 0, 0, -1, 1, 1, -1};
const int N = 2e3 + 5;
int n, m;
string mp[N], mp2[N];
map<string, string> shortcut;
map<string, int> ind;
set<string> seq;
void next(string &s) {
if (s[s.size() - 1] == 'z')
s.push_back('... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 7;
const long long INFL = 1e18 + 123;
const double PI = atan2(0, -1);
mt19937 tw(960172);
long long rnd(long long x, long long y) {
static uniform_int_distribution<long long> d;
return d(tw) % (y - x + 1) + x;
}
const int P = 239, MOD = 1e9 + 7;
vo... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | //package hel2018;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.Random;
public class A2 {
InputStream is;
PrintWriter out;
Strin... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
const long long B = 31;
const long long mod = 1e9 + 7;
const int maxn = 3000;
long long b_pow[maxn];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
b_pow[0] = 1LL;
for (int i = 1; i < maxn; i++) b_pow[i] = (b_pow[i - 1] * B) % mod;
int n, m;
cin >> n... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, m;
cin >> n >> m;
vector<string> vv1;
string str;
for (int i = 0; i < n; i++) {
cin >> str;
vv1.push_back(str);
}
vector<string> vv2;
for (int i = 0; i < m; i++) {
cin >> st... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
string q[2001], p[2001];
long long n, m, i, j, x, y, c[2001][2001], t[2001][2001], ans1[2001],
ans2[2001], ans3[2001], ans4[2001];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n >> m;
x = 1;
y = 1;
for (i = 0; i < 2001; i++) {
for... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
const int PRIME_BASE = 719;
const long long PRIME_MOD = 1110111110111ULL;
void mod(long long& h) {
if (h >= PRIME_MOD) h -= PRIME_MOD;
}
long long mulmod(long long a, long long b) {
long long res = 0;
while (a > 0) {
if (a & 1) {
res += b;
mod(res);
... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
inline int read() {
int ret = 0;
char c = getchar();
while (c < 48 || c > 57) c = getchar();
while (c >= 48 && c <= 57) ret = ret * 10 + c - 48, c = getchar();
return ret;
}
long long vv[50];
const int MO = 998244353;
inline int ksm(int p, long long k) {
vv[0] =... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | import java.util.*;
import java.lang.Math;
import java.io.*;
public class Solution
{
public static void main(String[] args) throws IOException
{
FastReader in=new FastReader(System.in);
int n=in.nextInt();
int m=in.nextInt();
String[] s1=new String[n];
String[] s2=new St... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
long long n, m, i, j, k, s;
cin >> n >> m;
vector<string> a(n), b(m);
vector<vector<long long>> aa(n, vector<long long>(m));
vector<vector<long long>> bb(m, vector<long long>(n));
for (i = 0; i < n; i++) ... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
long long n, m,
d = 26, pc[400069][3], ipc[400069][3], a[2069][2069], pwk,
dv[3] = {(long long)1e9 + 7, (long long)1e9 + 9, (long long)1e9 + 21};
map<array<long long, 3>, long long> pst;
long long pw(long long x, long long y, long long mo) {
if (!y) {
return 1... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
const int N = 2005, M = 205, M2 = 1e9 + 9;
char a[N][M], b[M][N];
int A[N], B[N];
int csa[N][M], csb[M][N];
int n, m, pp[N], inv[N];
int pw(int n, int p) {
if (!p) return 1;
long long tmp = pw(n, p / 2);
tmp = (tmp * tmp) % M2;
if (p & 1) tmp = (n * tmp) % M2;
ret... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
unsigned long long pw[2005], base = 13331, base2 = 237;
void preCalc() {
pw[0] = 1;
for (int i = 1; i < 2005; i++) pw[i] = (pw[i - 1] * base);
}
string s2[205];
unsigned long long H[205][2005], H1[2005], savedH[2005][2005];
void setHash(int m) {
for (int i = 0; i < m;... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
const int maxn = 2010;
const int p = (int)1e9 + 7, q = (int)1e9 + 9;
pair<int, int> operator+(pair<int, int> a, pair<int, int> b) {
a.first += b.first;
a.second += b.second;
if (a.first >= p) {
a.first -= p;
}
if (a.second >= q) {
a.second -= q;
}
retu... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
char a[2002][202], b[202][2002];
int main() {
int n, m;
cin >> n >> m;
char temp;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
cin >> temp;
a[i][j] = temp;
}
}
for (int i = 1; i <= m; i++) {
for (int j = 1; j <= n; j++) {... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
const long long N = 2020;
const long long base = 257;
const long long base2 = 263;
const long long inf = 1e9 + 7;
long long n, m;
string str;
long long hash_1[N][N], hash_2[N][N], P[N];
unordered_map<long long, int> mymap;
int main() {
ios::sync_with_stdio(0);
cin.tie(0... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
char X[2000][200];
char Y[200][2000];
unsigned long long XH[2000][200];
unsigned long long YH[200][2000];
unsigned long long XH2[2000][200];
unsigned long long YH2[200][2000];
unordered_map<unsigned long long, int> pos;
int size;
char s[2048];
int N, M;
unsigned long long b... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
const long long INF = 1e16;
const long long MOD = 1e15 + 9;
const int MAX = 100015;
int n, m;
char c1[2002][202], c2[202][2002];
long long v1[2002], v2[2002];
set<long long> s;
map<long long, long long> M;
int main() {
cin >> n >> m;
for (int i = 0; i < n; i++) {
fo... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
const int mod = 1e9 + 7;
const double eps = 1e-6;
const int N = 2e3 + 7;
unsigned long long h1[N], h2[N][N];
int n, m;
char s[N][N], t[N][N];
void init() {
for (int i = 1; i <= n; i++) {
unsigned long long h = 0;
for (int j = 1; j <= m; j++... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
char s1[2005][205], s2[205][2005];
long long ha1[2005], ha2[2005], q1 = 19240817, q2 = 1000000007, q1m = 1,
q2m = 1, tmp1, tmp2;
map<long long, int> mp;
int main() {
int n, m;
scanf("%d%d", &n, &m);
for (int i = 0; i < n; i++) {
sca... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, m;
cin >> n >> m;
vector<string> mp(n);
for (int i = 0; i < n; i++) cin >> mp[i];
vector<long long> fm(n - m + 1, 0);
for (int i = 0; i < n - m + 1; i++) {
long long cp = 1;
for (int j = 0... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 2e3 + 7;
const int maxm = 2e5 + 7;
int ar[maxn], m, n;
bool bo[maxn];
char ch1[maxn][maxn], ch2[maxn][maxn];
int ar1[maxn], ar2[maxn][maxn];
int mo = 1e9 + 9;
int isPrime(int a) {
for (int i = 2; i <= sqrt(a); i++) {
if (a % i... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | n, m = [int(x) for x in input().split()]
list1 = []
list2 = []
for i in range(n):
list1.append(input())
for j in range(m):
list2.append(input())
list3 = []
for i in range(n - m + 1):
y = ""
for j in range(m):
y += list1[j + i]
list3.append(y)
list4 = []
for i in range(n - m + 1):
y = ... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
const int maxn = 2000 + 5;
char s1[maxn][maxn], s2[maxn][maxn];
int main() {
int n, m;
scanf("%d%d", &n, &m);
for (int i = 0; i < n; i++) scanf("%s", &s1[i]);
for (int i = 0; i < m; i++) scanf("%s", &s2[i]);
int r, c;
for (int i = 0; i <= n - m; i++)
for (in... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
const int MAX_N = 2010, MAX_M = 210;
const unsigned long long h = 127;
map<unsigned long long, int> pos;
int n, m;
string tab1[MAX_N];
string tab2[MAX_N];
unsigned long long hash1[MAX_N], hash2[MAX_N], step[MAX_M * MAX_M];
int main() {
cin >> n >> m;
for (int i = 0; i <... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
int n, m;
unsigned long long has[2010], hass[2010][2010];
const unsigned long long base = 131;
map<unsigned long long, int> ma;
char s[2010];
unsigned long long hashs(char s[]) {
int len = strlen(s + 1);
unsigned long long ans = 0;
for (int i = 1; i <= len; ++i) ans =... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
int M = 0;
char m1[2003][205];
char m2[205][2005];
class hash_map {
struct Node {
int value;
Node* next;
};
int Hash(int line) {
int sum = 0;
int factor = 1;
int incr = 7;
for (int i = 0; i < M; ++i) {
for (int j = 0; j < M; ++j) {
... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int MAXN = 2e3 + 5;
int n, m;
char a[MAXN][205], b[205][MAXN];
int h[MAXN], l[205][MAXN];
bool judge(int x, int y) {
for (int i = 1; i <= m; i++)
if (h[x + i - 1] ^ l[i][y - 1] ^ l[i][y + m - 1]) return false;... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace ::std;
const long double PI = acos(-1);
const long long MOD = (1LL << 61) - 1;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long add(long long a, long long b, long long m = MOD) {
return a + b < m ? a + b : a + b - m;
}
long long mul(long... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.InputStreamReader;
import java.io.BufferedOutputStream;
import java.util.StringTokenizer;
import java.io.Closeable;
import... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
char a[2003][203], b[203][2003];
int Next[203];
int ok[2003], cnt;
void KMP(char *s1, char *s2, int m, int n) {
Next[0] = -1;
for (int i = 1, k = -1; i < m; i++) {
while (k >= 0 && s1[i] != s1[k + 1]) k = Next[k];
Next[i] = (s1[i] == s1[k + 1]) ? ++k : -1;
}
... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
map<string, int> s1, v;
int neg[2005], xo[2005];
string s, burt[205], s2;
int i, j, k, l, n, m;
int main() {
cin >> n >> m;
for (i = 1; i <= n; i++) {
cin >> s;
if (s1[s] == 0) {
s1[s] = i;
neg[i] = i;
} else
neg[i] = s1[s];
}
for (i = ... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
const int mo = 997;
int n, m, AA[2010], BB[210][2010];
char A[2010][210], B[210][2010], tmp[210][210];
int main() {
scanf("%d%d\n", &n, &m);
for (int i = 1; i <= n; ++i) {
scanf("%s\n", A[i] + 1);
for (int j = 1; j <= m; ++j) AA[i] = (AA[i] + (A[i][j] - 97 + 1) ... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
int n, m;
char mapp[3000][3000];
long long a[3000];
long long b[3000][3000];
long long GetHash(char *str, int m) {
long long res = 0;
for (int i = 0; i < m; i++) {
res = (res * 233 % 1000000009 + str[i] - 'a' + 1) % 1000000009;
}
return res;
}
void deBug() {
f... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
const long long A = 31, mod = 1000000033LL;
vector<string> read(int n) {
vector<string> ans(n);
for (auto &x : ans) cin >> x;
return ans;
}
vector<long long> hsh(vector<string> vec, long long a) {
vector<long long> ans;
for (auto x : vec) {
long long h = 0;
... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 9;
const int maxn = 2e3 + 7;
const int maxm = 2e5 + 7;
int ar[maxn], m, n;
bool bo[maxn];
char ch1[maxn][maxn], ch2[maxn][maxn];
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(0);
cin >> n >> m;
for (int i = 0; i < n; i++) cin >> c... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
const int N = 2000 + 5;
int n, m;
struct hash_table {
unsigned long long seed;
unsigned long long Hash[N], temp[N];
void Set(unsigned long long num) { seed = num; }
void work(char *s, int n) {
temp[0] = 1;
Hash[0] = 0;
for (int i = 1; i <= n; i++) temp[i... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
constexpr auto MOD = 1000000007LL;
constexpr auto LINF = (1LL << 60);
constexpr auto INF = 2147483647LL;
constexpr auto PI = 3.1415926535897932384626433;
constexpr auto EPS = 1... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
int N, M;
int Base = 131;
char A[2005][2005], B[2005][2005];
unsigned long long hashA[2005], hashB[2005][2005];
unsigned long long calR(int i) {
unsigned long long ans = 0;
for (int j = 1; j <= M; j++) {
ans = ans * Base + A[i][j];
}
return ans;
}
void calC(int ... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
char mp[2][2001][2001];
int main() {
int n, m;
cin >> n >> m;
for (int i = 0; i < n; i++) cin >> mp[0][i];
for (int i = 0; i < m; i++) cin >> mp[1][i];
int i, j;
for (i = 0; i <= n - m; i++) {
for (j = 0; j <= n - m; j++) {
bool ok = true;
for (i... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
inline int read() {
int x = 0, f = 1;
char ch = getchar();
while (!isdigit(ch)) {
if (ch == '-') f = -1;
ch = getchar();
}
while (isdigit(ch)) {
x = (x << 1) + (x << 3) + ch - '0';
ch = getchar();
}
return x * f;
}
int n, m;
char s1[2007][207],... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
const int N = 2005, M = 205;
long long p = 1000000007, add = 998244353, add2 = 973586311;
int n, m;
long long hha[N], hhb[N], ha[N], hb[N];
char a[N][N], b[N][N];
map<long long, int> mp;
int main() {
scanf("%d%d", &n, &m);
for (int i = 1; i <= n; i++) scanf("%s", a[i] +... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int MOD2 = 1e9 + 1234567;
const int H = 3001;
char s[3003][503], t[503][3003];
long long hsh[3003], h[3003];
long long getval(int l, int r) {
return (hsh[r] - hsh[l - 1] * h[r - l + 1] % MOD + MOD) % MOD;
}
long long num[505];
int main() {
... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
const int mod = 997;
int n, m, AA[2010], BB[210][2010];
char A[2010][210], B[210][2010];
int main() {
scanf("%d%d\n", &n, &m);
for (int i = 1; i <= n; ++i) {
scanf("%s\n", A[i] + 1);
for (int j = 1; j <= m; ++j) AA[i] = (AA[i] + (A[i][j] - 97 + 1) * j) % mod;
... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
string s[2010], t[205];
int id[2010], a[205];
map<string, int> mp;
int tot = 0;
int main() {
int n, m, i, j, k, l, tmp;
scanf("%d%d", &n, &m);
for (i = 0; i < n; i++) {
cin >> s[i];
if (!mp[s[i]])
mp[s[i]] = id[i] = ++tot;
else
id[i] = mp[s[i]]... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
template <typename T>
void out(T x) {
cout << x << endl;
exit(0);
}
using ll = long long;
const ll mod = 1e9 + 7;
const int maxn = 2005;
ll P, Q;
int n, m;
ll g1[maxn][maxn];
ll g2[maxn][maxn];
ll X[maxn];
ll Y[maxn][maxn];
ll pacc[maxn];
map<ll, int> mp;
ll prime(ll x)... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
const int maxn = 2000 + 5;
string s1[maxn], s2[maxn];
int main() {
int n, m;
cin >> n >> m;
for (int i = 0; i < n; i++) cin >> s1[i];
for (int i = 0; i < m; i++) cin >> s2[i];
for (int i = 0; i <= n - m; i++)
for (int j = 0; j <= n - m; j++) {
bool flag ... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
const long long N = 2005;
const long long mod = 1e9 + 7;
char a[N][N], b[N][N];
long long row[N], col[N], n, m;
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n >> m;
for (long long i = 1; i <= n; i++)
for (long long j = 1; j <= m... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
const int maxn = 1010;
const int inf = 0x3fffffff;
int n, m;
string s1[2005], s2[205];
unsigned long long ha1s1[2005], ha2s2[205][2005];
unsigned long long hash1(string s) {
unsigned long long ret = 0;
for (int i = 0; s[i]; i++) ret = ret * 131 + s[i];
return ret;
}
b... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.math.BigInteger;
import java.util.Random;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
int sum[210][2010], a[2010];
char s[210][2010];
int main() {
int sign[30] = {2, 3, 5, 7, 11, 13, 15, 17, 23, 29, 31, 34, 37, 41, 43,
47, 53, 57, 59, 61, 67, 71, 73, 79, 83, 87, 97, 101, 103};
int n, m;
scanf("%d%d", &n, &m);
for (int i = 1; i ... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
int m, n;
char s1[2010][210], s2[210][2010];
int phi[2010];
ull a[2010], b[210][2010], c[2010], deg[2010];
ull getHash(int i, int len) { return c[i + len] - c[i] * d... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
const int LIM = 2005;
struct HashTable2D {
const static long long BASE1 = 31, BASE2 = 43;
const static long long MOD = 1000000007;
long long pw1[LIM], pw2[LIM];
int row, col;
long long a[LIM][LIM];
void init(int _row, int _col) {
row = _row;
col = _col;
... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | n,m=list(map(int,input().split()))
s=[]
h=[]
mod=10**9
mod+=7
for i in range(n):
s=(input())
s=s.lower()
hw=0
for i in range(m):
hw+=ord(s[i])*(10**(m-i))
h.append(hw%mod)
h1=[[] for i in range(n-m+1)]
for i in range(m):
hw=0
s=input()
s=s.lower()
aux=[]
for i in range(m)... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
const int N = 2010, M = 210, PC = 3;
int p[PC] = {1000000007, 1000000009, 1000000011};
int n, m;
int m26[PC], m2626[PC];
char s[N];
int hsh1[N][PC], hsh2[M][N][PC];
int main() {
scanf("%d%d", &n, &m);
for (int k = 0; k < PC; ++k) {
m26[k] = 1;
for (int i = 1; i ... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
const int p1 = 233, p2 = 433;
long long a[2020][3], b[2020][3];
int nxt[2020];
char aa[2020][2020], bb[2020][2020];
long long hs[2020][3], hs2[2020][3];
map<pair<long long, long long>, int> vis;
int main() {
int ans, n, m, i, j, k;
long long sum1, sum2, tmp1, tmp2;
sc... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | import java.util.Scanner;
public class A2 {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int n = s.nextInt();
int m = s.nextInt();
s.nextLine();
char[][] fm = new char[n][m];
char[][] sm = new char[m][n];
int[] fr = new int[n];
int[][] sr = new int[m][n-m+1];
for(int ... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
long long a[2005], b[2005];
string temp[205];
int n, m;
long long minv;
long long mp[40005];
long long mip[205];
map<int, int> m1, m2;
int main() {
cin >> n >> m;
minv = 80216065;
mp[0] = mip[0] = 1;
for (int i = 1; i < 40005; i++) mp[i] = (mp[i - 1] * 256) % 402653... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
int lps[2001][2001];
string map1[2001], map2[2001];
void computeLps(int t) {
lps[t][0] = 0;
int k = 0;
for (int i = 1; i < map1[t].size(); ++i) {
while (k > 0 && map1[t][k] != map1[t][i]) k = lps[t][k - 1];
if (map1[t][k] == map1[t][i]) ++k;
lps[t][i] = k;... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
const long long N = 2e3 + 5, MOD = 1e9 + 7, BASE = 29;
int n, m;
int a[N][N], b[N][N];
long long Pow[N];
pair<long long, long long> ha[N][N], hb[N][N];
void read_data(int x, int y, int s[N][N]) {
for (int i = 1; i <= x; ++i)
for (int j = 1; j <= y; ++j) {
char t... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
const int N = 2005;
const long long mod = 1000000000039ll, base = 9971ll;
int n, m;
char a[N][205], b[205][N];
map<long long, int> f;
int main() {
scanf("%d%d", &n, &m);
for (int i = 1; i <= n; i++) scanf("%s", a[i] + 1);
for (int i = 1; i <= m; i++) scanf("%s", b[i] ... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
int get_hash(std::string& str) {
int ret = 0;
for (int i = 0; i < str.length(); ++i) {
ret += (i + 1) * (str[i] - 'a' + 1);
}
return ret;
}
int get_sum(std::string& str, int start, int len) {
int sum = 0;
for (int i = start; i < start + len; ++i) {
sum +... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
const int maxn = 2000 + 10;
int N, M;
char a[maxn][maxn], b[maxn][maxn];
unsigned long long ha[maxn][maxn], hb[maxn][maxn], tmp[maxn][maxn];
void CalcHash(unsigned long long h[][maxn], char a[][maxn], int n, int m) {
const unsigned long long B1 = 9973;
const unsigned lo... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | n, m = list(map(int, input().strip().split(' ')))
L, M = [], []
for i in range(n):
L.append(tuple(input().strip()))
for i in range(0, m):
M.append(tuple(input().strip()))
k=0
row, col = [], []
for i in range(n-m+1):
init, end = i, i+m
row.append(hash(tuple(L[init:end])))
D = []
for j in range(0, m):
D.ap... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using std::max;
using std::min;
using std::swap;
using ll = long long;
static constexpr size_t N = 1 << 19;
static constexpr size_t M = 1 << 19;
char ma[2020][220], mb[220][2020];
ll ha[20200], hb[20200];
ll const PA = 107;
ll const PB = 37;
int n, m;
int solve() {
scanf("%d%d\n", &n, &m);
... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
void getint(int &v) {
char ch, fu = 0;
for (ch = '*'; (ch < '0' || ch > '9') && ch != '-'; ch = getchar())
;
if (ch == '-') fu = 1, ch = getchar();
for (v = 0; ch >= '0' && ch <= '9'; ch = getchar()) v = v * 10 + ch - '0';
if (fu) v = -v;
}
const int MO = 1000... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
int n, m;
cin >> n >> m;
vector<string> A(n), B(m);
for (auto& s : A) cin >> s;
for (auto& s : B) cin >> s;
for (int i = 0; i < n; i++) {
int pos = -1;
while (pos + 1 < n) {
bool ok = 1;
pos = B[0].find... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
int n, m, base = 31;
char map1[2003][203], map2[203][2003];
long long mod = 1e9 + 7, hashMap1[2003][203], hashMap2[203][2003], power[2003],
squareMap1[2003], squareMap2[2003];
void Matching() {
long long hashSub = 0;
for (int i = 1; i <= n - m + 1; ++i) {
... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | n, m = list(map(int, input().strip().split(' ')))
mat1, mat2 = [], []
for i in range(0, n): mat1.append(tuple(input().strip()))
for i in range(0, m): mat2.append(tuple(input().strip()))
ix, jx, flg = -1, -1, 0
matr, matc = [], []
for i in range(0, n-m+1):
si, se = i, i+m
matr.append(hash(tuple(mat1[si:se])))
matcur2... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
int n, m;
char m1[2333][2333], m2[2333][2333];
const long long B1 = 233, B2 = 233333333;
long long h[2333], r[2333][2333];
int main() {
scanf("%d%d", &n, &m);
for (int i = 1; i <= n; ++i) {
scanf("%s", m1[i] + 1);
for (int j = 1; j <= m; ++j) h[i] = h[i] * B1 + ... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
const int N = 2000 + 5;
int n, m;
struct hash_table {
unsigned long long seed;
unsigned long long Hash[N], temp[N];
void Set(unsigned long long num) { seed = num; }
void work(char *s, int n) {
temp[0] = 1;
Hash[0] = 0;
for (int i = 1; i <= n; i++) temp[i... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
#pragma GCC optimize "trapv"
using namespace std;
const int INF = 1e9;
void _print(long long t) { cerr << t; }
void _print(int t) { cerr << t; }
void _print(string t) { cerr << t; }
void _print(char t) { cerr << t; }
void _print(long double t) { cerr << t; }
void _print(double t) { cerr << t; }... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
static const long long MAX_M = 201, MAX_N = 2001, MOD = 1e9 + 7;
long long _hash[MAX_M * MAX_M];
std::string map_a[MAX_N], map_b[MAX_M];
long long hash_a[MAX_N], hash_b[MAX_N];
long long hash(std::string &str) {
long long x = str.length();
for (long long i = 0; i < x; ++i)
if (i == 0)
... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7, p1 = 37, p2 = 23;
char s1[400005], s2[205][2005];
long long sump1[400005], sump2[400005];
pair<long long, long long> hash2[2005], hash1[400005];
pair<long long, long long> gethash1(int sta, int fin) {
long long h1 =
(hash1[fin].first -... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
vector<long long> p_pow;
const int p = 61;
long long myhash(string s) {
long long res = 0;
for (int i = 0; i < (int)(s).size(); i++) {
res += (s[i] - 'a' + 1) * p_pow[i];
}
return res;
}
int main() {
int n, m;
cin >... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
void JIZZ(string output = "") {
cout << output;
exit(0);
}
const long double PI = 3.14159265358979323846264338327950288;
const long double eps = 1e-13;
const long long mod = 865948511;
const long long p = 557;
long long invp;
long long pw(long long b, long long n, long ... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
const int maxn = 1010;
const int inf = 0x3fffffff;
const long long mod1 = 217636919;
const long long mod2 = 917120411;
int n, m;
string s1[2005], s2[205];
long long ha1s1[2005], ha1s2[205][2005];
long long ha2s1[2005], ha2s2[205][2005];
long long hash1(string s) {
long lo... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
const char nl = '\n';
const long long INF = 0x3f3f3f3f;
const long long INFLL = 0x3f3f3f3f3f3f3f3f;
const long long MOD = 1e9 + 7;
const long double EPS = 1e-10;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
int main() {
ios::sync_with_stdi... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
inline int read() {
int a = 0, f = 1;
char ch = getchar();
for (; !isdigit(ch); ch = getchar())
if (ch == '-') f = -1;
for (; isdigit(ch); ch = getchar()) a = (a << 3) + (a << 1) + ch - '0';
return a * f;
}
const int mod = 997;
const int N = 2e3 + 5;
const int... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
const int N = 2e3 + 7;
const int mod1 = 1e9 + 7;
const int mod2 = 1e8 + 7;
const int p = 1e4 + 7;
char a[N][N], b[N][N];
struct Node {
int x, y;
bool operator==(const Node k) const { return x == k.x && y == k.y; }
bool operator!=(const Node k) const { return x != k.x ... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
const int p = 131;
int n, m;
char a[2005][205], b[205][2005];
unsigned int ha[2005];
unsigned int s1[2005], s2[2005];
int main() {
scanf("%d%d", &n, &m);
for (int i = 0; i < n; ++i) {
scanf("%s", a[i]);
ha[i] = hash<string>()(string(a[i], a[i] + m));
}
for (... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
const long long int inf = 9e18;
long long int t, n, m, x;
vector<string> arr, brr;
vector<long long int> has2[2001], has1[2001];
long long int power(long long int x, long long int y, long long int p) {
long long int res = 1;
x %= p;
if (x == 0) return 0;
while (y > ... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
using namespace std;
string a[2005], b[2005];
int main() {
int n, m;
scanf("%d%d", &n, &m);
for (int i = 0; i < n; i++) cin >> a[i];
for (int i = 0; i < m; i++) cin >> b[i];
for (int i = 0; i <= n - m; i++) {
for (int j = 0; j <= n - m; j++) {
bool temp = true;
for (in... |
Problem: The stardate is 1983, and Princess Heidi is getting better at detecting the Death Stars. This time, two Rebel spies have yet again given Heidi two maps with the possible locations of the Death Star. Since she got rid of all double agents last time, she knows that both maps are correct, and indeed show the map ... | #include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse4")
using namespace std;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
long long dohash(const string& s) {
long long h = 0;
for (int(i) = 0; (i) < ((int)(s).size()); (i)++) {
h = h * 33 + s[i];
}
return h;
}
int main() {... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.