problem_id
stringlengths 6
6
| language
stringclasses 2
values | original_status
stringclasses 3
values | original_src
stringlengths 19
243k
| changed_src
stringlengths 19
243k
| change
stringclasses 3
values | i1
int64 0
8.44k
| i2
int64 0
8.44k
| j1
int64 0
8.44k
| j2
int64 0
8.44k
| error
stringclasses 270
values | stderr
stringlengths 0
226k
|
---|---|---|---|---|---|---|---|---|---|---|---|
p03250 | C++ | Runtime Error | #include <algorithm>
#include <iostream>
#include <vector>
int main() {
std::vector<int> vec(3);
std::cin >> vec.at(0) >> vec.at(1) >> vec.at(2);
std::sort(vec.begin(), vec.end());
std::cout << vec.at(3) * 10 + vec.at(0) + vec.at(1) << std::endl;
return 0;
} | #include <algorithm>
#include <iostream>
#include <vector>
int main() {
std::vector<int> vec(3);
std::cin >> vec.at(0) >> vec.at(1) >> vec.at(2);
std::sort(vec.begin(), vec.end());
std::cout << vec.at(2) * 10 + vec.at(0) + vec.at(1) << std::endl;
return 0;
} | replace | 9 | 10 | 9 | 10 | -6 | terminate called after throwing an instance of 'std::out_of_range'
what(): vector::_M_range_check: __n (which is 3) >= this->size() (which is 3)
|
p03250 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
vector<int> A;
cin >> A[0] >> A[1] >> A[2];
sort(A.begin(), A.end());
cout << A[0] + A[1] + A[2] * 10 << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
vector<int> A(3);
cin >> A[0] >> A[1] >> A[2];
sort(A.begin(), A.end());
cout << A[0] + A[1] + A[2] * 10 << endl;
return 0;
} | replace | 5 | 6 | 5 | 6 | -11 | |
p03250 | C++ | Runtime Error | #include <algorithm>
#include <iostream>
using namespace std;
int main() {
int num[3];
for (int i = 0; i < 3; i++) {
cin >> num[i];
}
sort(num, num + 3, greater<int>());
return (num[0] * 10 + num[1] + num[2]);
} | #include <algorithm>
#include <iostream>
using namespace std;
int main() {
int num[3];
for (int i = 0; i < 3; i++) {
cin >> num[i];
}
sort(num, num + 3, greater<int>());
int ret = (num[0] * 10 + num[1] + num[2]);
cout << ret << endl;
} | replace | 11 | 12 | 11 | 14 | 53 | |
p03251 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const double PI = 3.14159265358979;
const ll INF = pow(10, 18);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define rep(i, n) FOR(i, 0, n)
string abc = "abcdefghijklmnopqrstuvwxyz";
string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main() {
ll n, m, x, y;
cin >> n >> m >> x >> y;
vl a(n + 1), b(m + 1);
rep(i, n) { cin >> a[i]; }
a[n] = x;
rep(i, m) { cin >> b[i]; }
b[n] = y;
sort(a.begin(), a.end());
sort(b.begin(), b.end());
if (a[n] < b[0])
cout << "No War" << endl;
else
cout << "War" << endl;
} | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const double PI = 3.14159265358979;
const ll INF = pow(10, 18);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define rep(i, n) FOR(i, 0, n)
string abc = "abcdefghijklmnopqrstuvwxyz";
string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main() {
ll n, m, x, y;
cin >> n >> m >> x >> y;
vl a(n + 1), b(m + 1);
rep(i, n) { cin >> a[i]; }
a[n] = x;
rep(i, m) { cin >> b[i]; }
b[m] = y;
sort(a.begin(), a.end());
sort(b.begin(), b.end());
if (a[n] < b[0])
cout << "No War" << endl;
else
cout << "War" << endl;
} | replace | 21 | 22 | 21 | 22 | -6 | Fatal glibc error: malloc assertion failure in sysmalloc: (old_top == initial_top (av) && old_size == 0) || ((unsigned long) (old_size) >= MINSIZE && prev_inuse (old_top) && ((unsigned long) old_end & (pagesize - 1)) == 0)
|
p03251 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m, x, y;
cin >> n >> m >> x >> y;
vector<int> a(n + 1), b(n + 1);
for (int i = 0; i < n; i++)
cin >> a.at(i);
for (int i = 0; i < m; i++)
cin >> b.at(i);
a.at(n) = x;
b.at(m) = y;
sort(a.begin(), a.end());
sort(b.begin(), b.end());
if (a.at(n) < b.at(0) || a.at(0) > b.at(m))
cout << "No War" << endl;
else
cout << "War" << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m, x, y;
cin >> n >> m >> x >> y;
vector<int> a(n + 1), b(m + 1);
for (int i = 0; i < n; i++)
cin >> a.at(i);
for (int i = 0; i < m; i++)
cin >> b.at(i);
a.at(n) = x;
b.at(m) = y;
sort(a.begin(), a.end());
sort(b.begin(), b.end());
if (a.at(n) < b.at(0) || a.at(0) > b.at(m))
cout << "No War" << endl;
else
cout << "War" << endl;
}
| replace | 5 | 6 | 5 | 6 | 0 | |
p03251 | C++ | Runtime Error | #pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using datas = pair<ll, ll>;
using ddatas = pair<double, double>;
using tdata = pair<ll, datas>;
using vec = vector<ll>;
using mat = vector<vec>;
using pvec = vector<datas>;
using pmat = vector<pvec>;
#define For(i, a, b) for (i = a; i < (ll)b; i++)
#define bFor(i, a, b) for (i = a; i >= (ll)b; i--)
#define rep(i, N) For(i, 0, N)
#define rep1(i, N) For(i, 1, N)
#define brep(i, N) bFor(i, N - 1, 0)
#define all(v) (v).begin(), (v).end()
#define allr(v) (v).rbegin(), (v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define output(v) \
do { \
bool f = 0; \
for (auto outi : v) { \
cout << (f ? " " : "") << outi; \
f = 1; \
} \
cout << endl; \
} while (0)
const ll mod = 1000000007;
const ll inf = 1LL << 60;
const double PI = acos(-1);
const double eps = 1e-9;
template <class T> inline bool chmax(T &a, T b) {
bool x = a < b;
if (x)
a = b;
return x;
}
template <class T> inline bool chmin(T &a, T b) {
bool x = a > b;
if (x)
a = b;
return x;
}
void startupcpp() {
cin.tie(0);
ios::sync_with_stdio(false);
cout << fixed << setprecision(15);
}
double distance(ddatas &x, ddatas &y) {
double a = x.first - y.first, b = x.second - y.second;
return sqrt(a * a + b * b);
}
ll modinv(ll a) {
ll b = mod, u = 1, v = 0, t;
while (b) {
t = a / b;
a -= t * b;
swap(a, b);
u -= t * v;
swap(u, v);
}
return (u + mod) % mod;
}
ll moddevide(ll a, ll b) { return (a * modinv(b)) % mod; }
vec modncrlistp, modncrlistm;
ll modncr(ll n, ll r) {
ll i, size = modncrlistp.size();
if (size <= n) {
modncrlistp.resize(n + 1);
modncrlistm.resize(n + 1);
if (!size) {
modncrlistp[0] = modncrlistm[0] = 1;
size++;
}
For(i, size, n + 1) {
modncrlistp[i] = modncrlistp[i - 1] * i % mod;
modncrlistm[i] = modinv(modncrlistp[i]);
}
}
return modncrlistp[n] * modncrlistm[r] % mod * modncrlistm[n - r] % mod;
}
ll modpow(ll a, ll n) {
ll res = 1;
while (n) {
if (n & 1)
res = res * a % mod;
a = a * a % mod;
n >>= 1;
}
return res;
}
ll gcd(ll a, ll b) {
if (!b)
return a;
return (a % b == 0) ? b : gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll countdigits(ll n) {
ll ans = 0;
while (n) {
n /= 10;
ans++;
}
return ans;
}
ll sumdigits(ll n) {
ll ans = 0;
while (n) {
ans += n % 10;
n /= 10;
}
return ans;
}
void judgement(int a) {
if (a) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
if (a) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
int main() {
startupcpp();
ll i, N, M;
vec a(N), b(M);
cin >> a[0] >> b[0];
rep1(i, N) cin >> a[i];
rep1(i, M) cin >> b[i];
vrsort(a);
vsort(b);
if (a[0] < b[0])
cout << "No ";
cout << "War" << endl;
return 0;
} | #pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using datas = pair<ll, ll>;
using ddatas = pair<double, double>;
using tdata = pair<ll, datas>;
using vec = vector<ll>;
using mat = vector<vec>;
using pvec = vector<datas>;
using pmat = vector<pvec>;
#define For(i, a, b) for (i = a; i < (ll)b; i++)
#define bFor(i, a, b) for (i = a; i >= (ll)b; i--)
#define rep(i, N) For(i, 0, N)
#define rep1(i, N) For(i, 1, N)
#define brep(i, N) bFor(i, N - 1, 0)
#define all(v) (v).begin(), (v).end()
#define allr(v) (v).rbegin(), (v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define output(v) \
do { \
bool f = 0; \
for (auto outi : v) { \
cout << (f ? " " : "") << outi; \
f = 1; \
} \
cout << endl; \
} while (0)
const ll mod = 1000000007;
const ll inf = 1LL << 60;
const double PI = acos(-1);
const double eps = 1e-9;
template <class T> inline bool chmax(T &a, T b) {
bool x = a < b;
if (x)
a = b;
return x;
}
template <class T> inline bool chmin(T &a, T b) {
bool x = a > b;
if (x)
a = b;
return x;
}
void startupcpp() {
cin.tie(0);
ios::sync_with_stdio(false);
cout << fixed << setprecision(15);
}
double distance(ddatas &x, ddatas &y) {
double a = x.first - y.first, b = x.second - y.second;
return sqrt(a * a + b * b);
}
ll modinv(ll a) {
ll b = mod, u = 1, v = 0, t;
while (b) {
t = a / b;
a -= t * b;
swap(a, b);
u -= t * v;
swap(u, v);
}
return (u + mod) % mod;
}
ll moddevide(ll a, ll b) { return (a * modinv(b)) % mod; }
vec modncrlistp, modncrlistm;
ll modncr(ll n, ll r) {
ll i, size = modncrlistp.size();
if (size <= n) {
modncrlistp.resize(n + 1);
modncrlistm.resize(n + 1);
if (!size) {
modncrlistp[0] = modncrlistm[0] = 1;
size++;
}
For(i, size, n + 1) {
modncrlistp[i] = modncrlistp[i - 1] * i % mod;
modncrlistm[i] = modinv(modncrlistp[i]);
}
}
return modncrlistp[n] * modncrlistm[r] % mod * modncrlistm[n - r] % mod;
}
ll modpow(ll a, ll n) {
ll res = 1;
while (n) {
if (n & 1)
res = res * a % mod;
a = a * a % mod;
n >>= 1;
}
return res;
}
ll gcd(ll a, ll b) {
if (!b)
return a;
return (a % b == 0) ? b : gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll countdigits(ll n) {
ll ans = 0;
while (n) {
n /= 10;
ans++;
}
return ans;
}
ll sumdigits(ll n) {
ll ans = 0;
while (n) {
ans += n % 10;
n /= 10;
}
return ans;
}
void judgement(int a) {
if (a) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
if (a) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
int main() {
startupcpp();
ll i, N, M;
cin >> N >> M;
N++;
M++;
vec a(N), b(M);
cin >> a[0] >> b[0];
rep1(i, N) cin >> a[i];
rep1(i, M) cin >> b[i];
vrsort(a);
vsort(b);
if (a[0] < b[0])
cout << "No ";
cout << "War" << endl;
return 0;
} | insert | 143 | 143 | 143 | 146 | -11 | |
p03251 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;
int main() {
int n, m, x, y;
cin >> n >> m >> x >> y;
vector<int> a(n), b(m);
a[0] = x;
b[0] = y;
int t;
rep(i, n) cin >> a[i + 1];
rep(i, m) cin >> b[i + 1];
sort(a.begin(), a.end());
sort(b.begin(), b.end());
if (a[n] < b[0])
cout << "No War" << endl;
else
cout << "War" << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;
int main() {
int n, m, x, y;
cin >> n >> m >> x >> y;
vector<int> a(n + 1), b(m + 1);
a[0] = x;
b[0] = y;
int t;
rep(i, n) cin >> a[i + 1];
rep(i, m) cin >> b[i + 1];
sort(a.begin(), a.end());
sort(b.begin(), b.end());
if (a[n] < b[0])
cout << "No War" << endl;
else
cout << "War" << endl;
return 0;
} | replace | 8 | 9 | 8 | 9 | 0 | |
p03251 | C++ | Runtime Error | #include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
// const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
// const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};
int main() {
int n, m, x, y;
cin >> n >> m >> x >> y;
vector<int> a(n);
vector<int> b(n);
REP(i, n) cin >> a[i];
REP(i, m) cin >> b[i];
sort(ALL(a));
sort(ALL(b));
if (a[n - 1] < b[0]) {
if (x < b[0] && b[0] <= y) {
cout << "No War" << endl;
return 0;
}
}
cout << "War" << endl;
}
| #include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
// const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
// const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};
int main() {
int n, m, x, y;
cin >> n >> m >> x >> y;
vector<int> a(n);
vector<int> b(m);
REP(i, n) cin >> a[i];
REP(i, m) cin >> b[i];
sort(ALL(a));
sort(ALL(b));
if (a[n - 1] < b[0]) {
if (x < b[0] && b[0] <= y) {
cout << "No War" << endl;
return 0;
}
}
cout << "War" << endl;
}
| replace | 17 | 18 | 17 | 18 | 0 | |
p03251 | C++ | Runtime Error | #include <algorithm>
#include <iostream>
#include <math.h>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<ULL> VULL;
class MYCP {
public:
// 数値を区切って文字列にする
static string MakeString_LongLong(vector<long long> const &numbers,
string const &str) {
if (numbers.size() == 0)
return "";
string result = "" + to_string(numbers[0]);
for (long long i = 1; i < numbers.size(); i++) {
result += str;
result += to_string(numbers[i]);
}
return result;
}
// 空白で区切る為のオーバーロード
static string MakeString_LongLong(vector<long long> const &numbers) {
if (numbers.size() == 0)
return "";
string result = "" + to_string(numbers[0]);
for (long long i = 1; i < numbers.size(); i++) {
result += " ";
result += to_string(numbers[i]);
}
return result;
}
// 文字列の配列を改行を挟んでまとめる
static string MakeString_VectorString(vector<string> const &str) {
string result = "";
for (long long i = 0; i < str.size(); i++) {
result += str[i] + "\n";
}
return result;
}
// 文字列を必要な個数だけ読み取る
static vector<string> MyReadLineSplit(LL n) {
vector<string> str(n);
for (long long i = 0; i < n; i++) {
std::cin >> str[i];
}
return str;
}
// 数値を必要な個数だけ読み取る
static vector<long long> ReadInts(long long number) {
vector<long long> a(number);
for (int i = 0; i < number; i++) {
std::cin >> a[i];
}
return a;
}
// 渡された自然数が素数ならtureを返す
static bool PrimeCheck_Int(long long number) {
if (number < 2)
return false;
for (ULL i = 2; i * i <= number; i++) {
if (number % i == 0)
return false;
}
return true;
}
// 渡された数値以下の素数表を作る
static vector<long long> MakePrimeList(long long n) {
vector<long long> list;
LL i, j, p;
bool flag;
for (i = 2; i <= n; i++) {
flag = true;
for (j = 0; j < list.size(); j++) {
if (!(list[j] * list[j] <= i))
break;
if (i % list[j] == 0) {
flag = false;
break;
}
}
if (flag)
list.push_back(i);
}
return list;
}
// 文字列の分割
static vector<string> split(string const &str, char sep) {
vector<std::string> v; // 分割結果を格納するベクター
auto first = str.begin(); // テキストの最初を指すイテレータ
while (first != str.end()) { // テキストが残っている間ループ
auto last = first; // 分割文字列末尾へのイテレータ
while (last != str.end() &&
*last != sep) // 末尾 or セパレータ文字まで進める
last++;
v.push_back(string(first, last)); // 分割文字を出力
if (last != str.end())
last++;
first = last; // 次の処理のためにイテレータを設定
}
return v;
}
// 合計を求める
static LL Sum(vector<LL> a) {
LL i, sum = 0;
for (i = 0; i < a.size(); i++) {
sum += a[i];
}
return sum;
}
// 小文字ならtrueを返す
static bool Komoji(char a) {
if (a >= 'a' && a <= 'z')
return true;
return false;
}
// 大文字ならtrueを返す
static bool Oomoji(char a) {
if (a >= 'A' && a <= 'Z')
return true;
return false;
}
static LL SaidaiKouyakuSuu(LL a, LL b) {
LL temp;
if (a < b) {
temp = b;
b = a;
a = temp;
}
while (true) {
temp = a % b;
a = b;
b = temp;
if (b == 0)
break;
}
return a;
}
static LL SaisyouKoubaiSuu(LL a, LL b) {
return (a / SaidaiKouyakuSuu(a, b)) * b;
}
};
// 累積和を求めるクラス
class Syakutori {
private:
vector<LL> list;
public:
void MakeArray(vector<LL> data) {
LL i;
list = data;
list.push_back(0);
list[0] = 0;
for (i = 1; i < list.size(); i++) {
list[i] = list[i - 1] + data[i - 1];
}
}
LL Sum(LL start, LL end) {
if (end < start) {
cout << "startがendより大きいです";
return 0;
}
if (start < 0 || end >= list.size()) {
cout << "範囲が異常";
return 0;
}
return list[end] - list[start];
}
};
int main(void) {
int n, m, x, y, judge;
cin >> n >> m >> x >> y;
vector<int> xx(n), yy(m);
for (int i = 0; i < n; i++)
cin >> xx.at(i);
for (int i = 0; i < m; i++)
cin >> yy.at(i);
sort(xx.begin(), xx.end());
sort(yy.begin(), yy.end());
if ((yy.at(0) - xx.at(n)) > 0)
cout << "No War" << endl;
else
cout << "War" << endl;
return 0;
}
| #include <algorithm>
#include <iostream>
#include <math.h>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<ULL> VULL;
class MYCP {
public:
// 数値を区切って文字列にする
static string MakeString_LongLong(vector<long long> const &numbers,
string const &str) {
if (numbers.size() == 0)
return "";
string result = "" + to_string(numbers[0]);
for (long long i = 1; i < numbers.size(); i++) {
result += str;
result += to_string(numbers[i]);
}
return result;
}
// 空白で区切る為のオーバーロード
static string MakeString_LongLong(vector<long long> const &numbers) {
if (numbers.size() == 0)
return "";
string result = "" + to_string(numbers[0]);
for (long long i = 1; i < numbers.size(); i++) {
result += " ";
result += to_string(numbers[i]);
}
return result;
}
// 文字列の配列を改行を挟んでまとめる
static string MakeString_VectorString(vector<string> const &str) {
string result = "";
for (long long i = 0; i < str.size(); i++) {
result += str[i] + "\n";
}
return result;
}
// 文字列を必要な個数だけ読み取る
static vector<string> MyReadLineSplit(LL n) {
vector<string> str(n);
for (long long i = 0; i < n; i++) {
std::cin >> str[i];
}
return str;
}
// 数値を必要な個数だけ読み取る
static vector<long long> ReadInts(long long number) {
vector<long long> a(number);
for (int i = 0; i < number; i++) {
std::cin >> a[i];
}
return a;
}
// 渡された自然数が素数ならtureを返す
static bool PrimeCheck_Int(long long number) {
if (number < 2)
return false;
for (ULL i = 2; i * i <= number; i++) {
if (number % i == 0)
return false;
}
return true;
}
// 渡された数値以下の素数表を作る
static vector<long long> MakePrimeList(long long n) {
vector<long long> list;
LL i, j, p;
bool flag;
for (i = 2; i <= n; i++) {
flag = true;
for (j = 0; j < list.size(); j++) {
if (!(list[j] * list[j] <= i))
break;
if (i % list[j] == 0) {
flag = false;
break;
}
}
if (flag)
list.push_back(i);
}
return list;
}
// 文字列の分割
static vector<string> split(string const &str, char sep) {
vector<std::string> v; // 分割結果を格納するベクター
auto first = str.begin(); // テキストの最初を指すイテレータ
while (first != str.end()) { // テキストが残っている間ループ
auto last = first; // 分割文字列末尾へのイテレータ
while (last != str.end() &&
*last != sep) // 末尾 or セパレータ文字まで進める
last++;
v.push_back(string(first, last)); // 分割文字を出力
if (last != str.end())
last++;
first = last; // 次の処理のためにイテレータを設定
}
return v;
}
// 合計を求める
static LL Sum(vector<LL> a) {
LL i, sum = 0;
for (i = 0; i < a.size(); i++) {
sum += a[i];
}
return sum;
}
// 小文字ならtrueを返す
static bool Komoji(char a) {
if (a >= 'a' && a <= 'z')
return true;
return false;
}
// 大文字ならtrueを返す
static bool Oomoji(char a) {
if (a >= 'A' && a <= 'Z')
return true;
return false;
}
static LL SaidaiKouyakuSuu(LL a, LL b) {
LL temp;
if (a < b) {
temp = b;
b = a;
a = temp;
}
while (true) {
temp = a % b;
a = b;
b = temp;
if (b == 0)
break;
}
return a;
}
static LL SaisyouKoubaiSuu(LL a, LL b) {
return (a / SaidaiKouyakuSuu(a, b)) * b;
}
};
// 累積和を求めるクラス
class Syakutori {
private:
vector<LL> list;
public:
void MakeArray(vector<LL> data) {
LL i;
list = data;
list.push_back(0);
list[0] = 0;
for (i = 1; i < list.size(); i++) {
list[i] = list[i - 1] + data[i - 1];
}
}
LL Sum(LL start, LL end) {
if (end < start) {
cout << "startがendより大きいです";
return 0;
}
if (start < 0 || end >= list.size()) {
cout << "範囲が異常";
return 0;
}
return list[end] - list[start];
}
};
int main(void) {
int n, m, x, y, judge;
cin >> n >> m >> x >> y;
vector<int> xx(n), yy(m);
for (int i = 0; i < n; i++)
cin >> xx.at(i);
for (int i = 0; i < m; i++)
cin >> yy.at(i);
sort(xx.begin(), xx.end());
sort(yy.begin(), yy.end());
if ((yy.at(0) - xx.at(n - 1)) > 0 && yy.at(0) > x && xx.at(n - 1) < y)
cout << "No War" << endl;
else
cout << "War" << endl;
return 0;
}
| replace | 218 | 219 | 218 | 219 | -6 | terminate called after throwing an instance of 'std::out_of_range'
what(): vector::_M_range_check: __n (which is 3) >= this->size() (which is 3)
|
p03251 | C++ | Runtime Error | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
string res = "War";
vector<int> x(n), y(m);
cin >> x[0] >> y[0];
for (int i = 1; i < n + 1; i++) {
cin >> x[i];
}
for (int i = 1; i < m + 1; i++) {
cin >> y[i];
}
int mx = *max_element(x.begin(), x.end());
int my = *min_element(y.begin(), y.end());
if (mx < my) {
res = "No War";
}
cout << res << "\n";
}
| #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
string res = "War";
vector<int> x(n + 1), y(m + 1);
cin >> x[0] >> y[0];
for (int i = 1; i < n + 1; i++) {
cin >> x[i];
}
for (int i = 1; i < m + 1; i++) {
cin >> y[i];
}
int mx = *max_element(x.begin(), x.end());
int my = *min_element(y.begin(), y.end());
if (mx < my) {
res = "No War";
}
cout << res << "\n";
}
| replace | 9 | 10 | 9 | 10 | 0 | |
p03251 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, M, X, Y;
cin >> N >> M >> X >> Y;
vector<int> x(N);
vector<int> y(N);
for (int i = 0; i < N; i++) {
cin >> x.at(i);
}
for (int i = 0; i < M; i++) {
cin >> y.at(i);
}
int maxx = -101, miny = 101;
for (int i = 0; i < N; i++) {
if (maxx < x.at(i)) {
maxx = x.at(i); // xの最大値
}
}
for (int i = 0; i < M; i++) {
if (miny > y.at(i)) {
miny = y.at(i); // yの最小値
}
}
if (maxx < X) {
maxx = X;
}
if (miny > Y) {
miny = Y;
}
if (maxx < miny) {
cout << "No War" << endl;
} else {
cout << "War" << endl;
}
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, M, X, Y;
cin >> N >> M >> X >> Y;
vector<int> x(N);
vector<int> y(M);
for (int i = 0; i < N; i++) {
cin >> x.at(i);
}
for (int i = 0; i < M; i++) {
cin >> y.at(i);
}
int maxx = -101, miny = 101;
for (int i = 0; i < N; i++) {
if (maxx < x.at(i)) {
maxx = x.at(i); // xの最大値
}
}
for (int i = 0; i < M; i++) {
if (miny > y.at(i)) {
miny = y.at(i); // yの最小値
}
}
if (maxx < X) {
maxx = X;
}
if (miny > Y) {
miny = Y;
}
if (maxx < miny) {
cout << "No War" << endl;
} else {
cout << "War" << endl;
}
} | replace | 6 | 7 | 6 | 7 | 0 | |
p03251 | C++ | Runtime Error | #include <algorithm>
#include <array>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, a, n) for (int i = a; i < (n); i++)
#define all(in) in.begin(), in.end()
const int INF = 1e9;
const int MOD = 1e9 + 7;
// #define MAX_N 100
bool is_war(vector<int> x, vector<int> y) {
loop(Z, -100, 101) {
bool is_ok = true;
rep(i, x.size()) {
if (x[i] >= Z) {
is_ok = false;
}
}
rep(i, y.size()) {
if (y[i] < Z) {
is_ok = false;
}
}
if (is_ok)
return false;
}
return true;
}
int main() {
int X, Y, N, M;
cin >> N >> M >> X >> Y;
vector<int> x(N), y(M);
rep(i, N) cin >> x[i];
rep(i, M) cin >> y[i];
x[N] = X, y[M] = Y;
if (is_war(x, y)) {
cout << "War" << endl;
} else {
cout << "No War" << endl;
}
return 0;
} | #include <algorithm>
#include <array>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, a, n) for (int i = a; i < (n); i++)
#define all(in) in.begin(), in.end()
const int INF = 1e9;
const int MOD = 1e9 + 7;
// #define MAX_N 100
bool is_war(vector<int> x, vector<int> y) {
loop(Z, -100, 101) {
bool is_ok = true;
rep(i, x.size()) {
if (x[i] >= Z) {
is_ok = false;
}
}
rep(i, y.size()) {
if (y[i] < Z) {
is_ok = false;
}
}
if (is_ok)
return false;
}
return true;
}
int main() {
int X, Y, N, M;
cin >> N >> M >> X >> Y;
vector<int> x(N + 1), y(M + 1);
rep(i, N) cin >> x[i];
rep(i, M) cin >> y[i];
x[N] = X, y[M] = Y;
if (is_war(x, y)) {
cout << "War" << endl;
} else {
cout << "No War" << endl;
}
return 0;
} | replace | 43 | 44 | 43 | 44 | 0 | |
p03251 | C++ | Runtime Error | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>
#pragma region Macros
#define int long long
#define double long double
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
#define REP(i, n) for (int i = 1; i <= n; i++)
#define LAST(x) x[x.size() - 1]
#define ALL(x) (x).begin(), (x).end()
#define swap(a, b) (a += b, b = a - b, a -= b)
#define DIVCEIL(a, b) ((a + b - 1) / b)
// int CHMAX
int intpow(int a, int n) {
// a^nのint ver
if (n == 0)
return 1;
else {
rep(i, n - 1) a *= a;
return a;
}
}
int MODPOW(int a, int n, int mod) {
// a^n mod
int ans = 1;
while (n > 0) {
if (n & 1)
ans = ans * a % mod;
a = a * a % mod;
n >>= 1;
}
return ans;
}
int FACT(int a) {
if (a == 0)
return 1;
else
return a * FACT(a - 1);
}
int MODFACT(int a, int mod) {
if (a == 0)
return 1;
else
return (a * FACT(a - 1)) % mod;
}
int nPr(int n, int r) {
int s = n - r + 1;
int sum = 1;
for (int i = s; i <= n; i++)
sum *= i;
return sum;
}
int MODnPr(int n, int r, int mod) {
int s = n - r + 1;
int sum = 1;
for (int i = s; i <= n; i++) {
sum *= i;
sum = sum % MOD;
}
return sum;
}
// int nCr(int n, int r)
int nCr2(int n, int r) { return FACT(n) / (FACT(r) * FACT(n - r)); }
int GCD(int a, int b) {
if (a < b)
swap(a, b);
if (b == 0)
return a;
if (a % b == 0)
return b;
return GCD(b, a % b);
}
int LCM(int a, int b) { return a * b / GCD(a, b); }
int NUMOFDIV(int n) {
// 約数の数(だっけ?)
int ans = 0;
REP(i, n) {
if (n % i == 0)
ans++;
}
return ans;
}
int CEIL1(int n) {
// 1桁目切り上げ
return (n + 9) / 10 * 10;
}
int GetDigit(int n) { return log10(n) + 1; }
int DIGIT(int n, int k) {
// nのk桁目
rep(i, k - 1) n /= 10;
return n % 10;
}
int DIGITSUM(int n) {
int sum = 0, dig;
while (n) {
dig = n % 10;
sum += dig;
n /= 10;
}
return sum;
}
int DIVTIME(int n, int k) {
// nをkで何回割れるか的な
int div = 0;
while (n % k == 0) {
div++;
n /= k;
}
return div;
}
int binary(int n) {
// 10進数→2進数
int ans = 0;
for (int i = 0; n > 0; i++) {
ans += n % 2 * intpow(10, i);
n /= 2;
}
return ans;
}
int intabs(int n) {
if (n < 0)
return -1 * n;
else
return n;
}
double LOG(int a, int b) { return log(b) / log(a); }
double DISTANCE(int x1, int y1, int x2, int y2) {
return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
inline bool BETWEEN(int x, int min, int max) {
if (min <= x && x <= max)
return true;
else
return false;
}
inline bool between(int x, int min, int max) {
if (min < x && x < max)
return true;
else
return false;
}
inline bool PRIMEOR(int x) {
if (x == 1)
return false;
if (x == 2)
return true;
if (x % 2 == 0)
return false;
double sqrtx = sqrt(x);
for (int i = 3; i <= sqrtx; i += 2) {
if (x % i == 0)
return false;
}
return true;
}
bool SQRTOR(int n) {
if (sqrt(n) == (int)sqrt(n))
return true;
else
return false;
}
// 順位付け
using namespace std;
#pragma endregion
signed main() {
int N, M, X, Y;
cin >> N >> M >> X >> Y;
vector<int> x(N), y(M);
rep(i, N) cin >> x[i];
rep(i, M) cin >> x[i];
int xmax = *max_element(ALL(x));
int ymin = *min_element(ALL(y));
string ans = "War";
REP(i, Y - X) {
if (xmax < X + i && ymin >= X + i)
ans = "No War";
}
cout << ans;
} | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>
#pragma region Macros
#define int long long
#define double long double
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
#define REP(i, n) for (int i = 1; i <= n; i++)
#define LAST(x) x[x.size() - 1]
#define ALL(x) (x).begin(), (x).end()
#define swap(a, b) (a += b, b = a - b, a -= b)
#define DIVCEIL(a, b) ((a + b - 1) / b)
// int CHMAX
int intpow(int a, int n) {
// a^nのint ver
if (n == 0)
return 1;
else {
rep(i, n - 1) a *= a;
return a;
}
}
int MODPOW(int a, int n, int mod) {
// a^n mod
int ans = 1;
while (n > 0) {
if (n & 1)
ans = ans * a % mod;
a = a * a % mod;
n >>= 1;
}
return ans;
}
int FACT(int a) {
if (a == 0)
return 1;
else
return a * FACT(a - 1);
}
int MODFACT(int a, int mod) {
if (a == 0)
return 1;
else
return (a * FACT(a - 1)) % mod;
}
int nPr(int n, int r) {
int s = n - r + 1;
int sum = 1;
for (int i = s; i <= n; i++)
sum *= i;
return sum;
}
int MODnPr(int n, int r, int mod) {
int s = n - r + 1;
int sum = 1;
for (int i = s; i <= n; i++) {
sum *= i;
sum = sum % MOD;
}
return sum;
}
// int nCr(int n, int r)
int nCr2(int n, int r) { return FACT(n) / (FACT(r) * FACT(n - r)); }
int GCD(int a, int b) {
if (a < b)
swap(a, b);
if (b == 0)
return a;
if (a % b == 0)
return b;
return GCD(b, a % b);
}
int LCM(int a, int b) { return a * b / GCD(a, b); }
int NUMOFDIV(int n) {
// 約数の数(だっけ?)
int ans = 0;
REP(i, n) {
if (n % i == 0)
ans++;
}
return ans;
}
int CEIL1(int n) {
// 1桁目切り上げ
return (n + 9) / 10 * 10;
}
int GetDigit(int n) { return log10(n) + 1; }
int DIGIT(int n, int k) {
// nのk桁目
rep(i, k - 1) n /= 10;
return n % 10;
}
int DIGITSUM(int n) {
int sum = 0, dig;
while (n) {
dig = n % 10;
sum += dig;
n /= 10;
}
return sum;
}
int DIVTIME(int n, int k) {
// nをkで何回割れるか的な
int div = 0;
while (n % k == 0) {
div++;
n /= k;
}
return div;
}
int binary(int n) {
// 10進数→2進数
int ans = 0;
for (int i = 0; n > 0; i++) {
ans += n % 2 * intpow(10, i);
n /= 2;
}
return ans;
}
int intabs(int n) {
if (n < 0)
return -1 * n;
else
return n;
}
double LOG(int a, int b) { return log(b) / log(a); }
double DISTANCE(int x1, int y1, int x2, int y2) {
return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
inline bool BETWEEN(int x, int min, int max) {
if (min <= x && x <= max)
return true;
else
return false;
}
inline bool between(int x, int min, int max) {
if (min < x && x < max)
return true;
else
return false;
}
inline bool PRIMEOR(int x) {
if (x == 1)
return false;
if (x == 2)
return true;
if (x % 2 == 0)
return false;
double sqrtx = sqrt(x);
for (int i = 3; i <= sqrtx; i += 2) {
if (x % i == 0)
return false;
}
return true;
}
bool SQRTOR(int n) {
if (sqrt(n) == (int)sqrt(n))
return true;
else
return false;
}
// 順位付け
using namespace std;
#pragma endregion
signed main() {
int N, M, X, Y;
cin >> N >> M >> X >> Y;
vector<int> x(N), y(M);
rep(i, N) cin >> x[i];
rep(i, M) cin >> y[i];
int xmax = *max_element(ALL(x));
int ymin = *min_element(ALL(y));
string ans = "War";
REP(i, Y - X) {
if (xmax < X + i && ymin >= X + i)
ans = "No War";
}
cout << ans;
} | replace | 181 | 182 | 181 | 182 | 0 | |
p03251 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c, d, g;
cin >> a >> b >> c >> d;
vector<int> e(a);
vector<int> f(b);
for (int i = 0; i < a; i++)
cin >> e.at(i);
for (int i = 0; i < b; i++)
cin >> f.at(i);
sort(e.begin(), e.end());
sort(f.begin(), f.end());
/*if(e.at(a)<g && g<=f.at(1) && a<g && g<=b)
cout << "No War";
else
cout << "War"*/
for (int i = c + 1; i <= d; i++) {
if (e.at(a) < i && i <= f.at(0)) {
cout << "No War" << endl;
break;
} else if (i == d)
cout << "War" << endl;
}
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int a, b, c, d, g;
cin >> a >> b >> c >> d;
vector<int> e(a);
vector<int> f(b);
for (int i = 0; i < a; i++)
cin >> e.at(i);
for (int i = 0; i < b; i++)
cin >> f.at(i);
sort(e.begin(), e.end());
sort(f.begin(), f.end());
/*if(e.at(a)<g && g<=f.at(1) && a<g && g<=b)
cout << "No War";
else
cout << "War"*/
for (int i = c + 1; i <= d; i++) {
if (e.at(a - 1) < i && i <= f.at(0)) {
cout << "No War" << endl;
break;
} else if (i == d)
cout << "War" << endl;
}
}
| replace | 19 | 20 | 19 | 20 | -6 | terminate called after throwing an instance of 'std::out_of_range'
what(): vector::_M_range_check: __n (which is 3) >= this->size() (which is 3)
|
p03251 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, M, X, Y;
cin >> N >> M >> X >> Y;
vector<int> kuni_x(N);
vector<int> kuni_y(N);
for (int i = 0; i < N; i++) {
cin >> kuni_x.at(i);
}
for (int i = 0; i < M; i++) {
cin >> kuni_y.at(i);
}
int max_x = kuni_x.at(0);
for (int i = 1; i < N; i++) {
max_x = max(max_x, kuni_x.at(i));
}
int min_y = kuni_y.at(0);
for (int i = 1; i < M; i++) {
min_y = min(min_y, kuni_y.at(i));
}
if (min_y <= max_x) {
cout << "War" << endl;
} else {
int count = 0;
for (int i = max_x; i < min_y; i++) {
if (X <= i && i < Y) {
count++;
}
}
if (count >= 1) {
cout << "No War" << endl;
} else {
cout << "War" << endl;
}
}
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int N, M, X, Y;
cin >> N >> M >> X >> Y;
vector<int> kuni_x(N);
vector<int> kuni_y(M);
for (int i = 0; i < N; i++) {
cin >> kuni_x.at(i);
}
for (int i = 0; i < M; i++) {
cin >> kuni_y.at(i);
}
int max_x = kuni_x.at(0);
for (int i = 1; i < N; i++) {
max_x = max(max_x, kuni_x.at(i));
}
int min_y = kuni_y.at(0);
for (int i = 1; i < M; i++) {
min_y = min(min_y, kuni_y.at(i));
}
if (min_y <= max_x) {
cout << "War" << endl;
} else {
int count = 0;
for (int i = max_x; i < min_y; i++) {
if (X <= i && i < Y) {
count++;
}
}
if (count >= 1) {
cout << "No War" << endl;
} else {
cout << "War" << endl;
}
}
}
| replace | 7 | 8 | 7 | 8 | 0 | |
p03251 | C++ | Runtime Error | #include "algorithm"
#include "bitset"
#include "climits"
#include "cmath"
#include "cstdio"
#include "functional"
#include "iomanip"
#include "iostream"
#include "list"
#include "map"
#include "numeric"
#include "queue"
#include "random"
#include "set"
#include "stack"
#include "string"
#include "unordered_map"
#include "unordered_set"
using namespace std;
const long long int MOD = 1000000007;
long long int N, M, K, H, W, L, R;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> N >> M >> L >> R;
vector<int> v(L);
for (int i = 0; i < L; i++)
cin >> v[i];
v.push_back(N);
sort(v.begin(), v.end());
vector<int> w(R);
for (int i = 0; i < R; i++)
cin >> w[i];
w.push_back(M);
sort(w.begin(), w.end());
if (v.back() < w.front()) {
cout << "No War\n";
} else {
cout << "War\n";
}
return 0;
} | #include "algorithm"
#include "bitset"
#include "climits"
#include "cmath"
#include "cstdio"
#include "functional"
#include "iomanip"
#include "iostream"
#include "list"
#include "map"
#include "numeric"
#include "queue"
#include "random"
#include "set"
#include "stack"
#include "string"
#include "unordered_map"
#include "unordered_set"
using namespace std;
const long long int MOD = 1000000007;
long long int N, M, K, H, W, L, R;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> L >> R >> N >> M;
vector<int> v(L);
for (int i = 0; i < L; i++)
cin >> v[i];
v.push_back(N);
sort(v.begin(), v.end());
vector<int> w(R);
for (int i = 0; i < R; i++)
cin >> w[i];
w.push_back(M);
sort(w.begin(), w.end());
if (v.back() < w.front()) {
cout << "No War\n";
} else {
cout << "War\n";
}
return 0;
} | replace | 29 | 30 | 29 | 30 | 0 | |
p03251 | C++ | Runtime Error | #include <algorithm>
#include <climits>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define P pair<int, int>
#define debug(x) cout << #x << ": " << x << ", "
#define debugln(x) cout << #x << ": " << x << '\n'
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n, m, X, Y;
cin >> n >> m >> X >> Y;
vector<int> x(n), y(m);
rep(i, n) { cin >> x.at(i); }
rep(i, m) { cin >> y.at(i); }
sort(x.begin(), x.end());
sort(y.begin(), y.end());
for (int i = x.at(n) + 1; i <= y.at(0); i++) {
if (X < i && i <= Y) {
cout << "No War" << endl;
return 0;
}
}
cout << "War" << endl;
} | #include <algorithm>
#include <climits>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define P pair<int, int>
#define debug(x) cout << #x << ": " << x << ", "
#define debugln(x) cout << #x << ": " << x << '\n'
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n, m, X, Y;
cin >> n >> m >> X >> Y;
vector<int> x(n), y(m);
rep(i, n) { cin >> x.at(i); }
rep(i, m) { cin >> y.at(i); }
sort(x.begin(), x.end());
sort(y.begin(), y.end());
for (int i = x.at(n - 1) + 1; i <= y.at(0); i++) {
if (X < i && i <= Y) {
cout << "No War" << endl;
return 0;
}
}
cout << "War" << endl;
} | replace | 35 | 36 | 35 | 36 | -6 | terminate called after throwing an instance of 'std::out_of_range'
what(): vector::_M_range_check: __n (which is 3) >= this->size() (which is 3)
|
p03251 | C++ | Runtime Error | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
using namespace std;
int main() {
int n, m, x, y;
cin >> n >> m >> x >> y;
vector<int> A(n);
rep(i, n) cin >> A[i];
A.push_back(x);
sort(A.rbegin(), A.rend());
int AMax = A[0];
vector<int> B(n);
rep(i, m) cin >> B[i];
B.push_back(y);
sort(B.begin(), B.end());
int BMin = B[0];
if (AMax < BMin)
cout << "No War" << endl;
else
cout << "War" << endl;
return 0;
}
| #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
using namespace std;
int main() {
int n, m, x, y;
cin >> n >> m >> x >> y;
vector<int> A(n);
rep(i, n) cin >> A[i];
A.push_back(x);
sort(A.rbegin(), A.rend());
int AMax = A[0];
vector<int> B(m);
rep(i, m) cin >> B[i];
B.push_back(y);
sort(B.begin(), B.end());
int BMin = B[0];
if (AMax < BMin)
cout << "No War" << endl;
else
cout << "War" << endl;
return 0;
}
| replace | 14 | 15 | 14 | 15 | 0 | |
p03251 | C++ | Runtime Error | #include <bits/stdc++.h>
typedef long long ll;
using namespace std;
// for(int i = 0; i<n; i++)
int main() {
int n, m;
cin >> n >> m;
vector<int> a(n + 1), b(n + 1);
cin >> a[0] >> b[0];
int amax = a[0];
int bmin = b[0];
for (int i = 1; i <= n; i++) {
cin >> a[i];
amax = max(amax, a[i]);
}
for (int i = 1; i <= m; i++) {
cin >> b[i];
bmin = min(bmin, b[i]);
}
cout << (amax < bmin ? "No War" : "War") << endl;
return 0;
} | #include <bits/stdc++.h>
typedef long long ll;
using namespace std;
// for(int i = 0; i<n; i++)
int main() {
int n, m;
cin >> n >> m;
int a[105], b[105];
cin >> a[0] >> b[0];
int amax = a[0];
int bmin = b[0];
for (int i = 1; i <= n; i++) {
cin >> a[i];
amax = max(amax, a[i]);
}
for (int i = 1; i <= m; i++) {
cin >> b[i];
bmin = min(bmin, b[i]);
}
cout << (amax < bmin ? "No War" : "War") << endl;
return 0;
} | replace | 8 | 9 | 8 | 9 | 0 | |
p03251 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
const int INF = 1000000000;
const long INF64 = 9223372036854775807;
const int MOD = 1000000007;
int main() {
int n, m, xx, yy;
std::cin >> n >> m >> xx >> yy;
std::vector<int> x(n);
rep(i, n) std::cin >> x[i];
std::vector<int> y(n);
rep(i, m) std::cin >> y[i];
int maxx = xx, miny = yy;
bool han = false;
rep(i, n) { maxx = max(maxx, x[i]); }
rep(i, m) { miny = min(miny, y[i]); }
if (maxx < miny)
std::cout << "No War" << std::endl;
else
std::cout << "War" << std::endl;
}
| #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
const int INF = 1000000000;
const long INF64 = 9223372036854775807;
const int MOD = 1000000007;
int main() {
int n, m, xx, yy;
std::cin >> n >> m >> xx >> yy;
std::vector<int> x(n);
rep(i, n) std::cin >> x[i];
std::vector<int> y(m);
rep(i, m) std::cin >> y[i];
int maxx = xx, miny = yy;
bool han = false;
rep(i, n) { maxx = max(maxx, x[i]); }
rep(i, m) { miny = min(miny, y[i]); }
if (maxx < miny)
std::cout << "No War" << std::endl;
else
std::cout << "War" << std::endl;
} | replace | 15 | 16 | 15 | 16 | 0 | |
p03251 | C++ | Runtime Error | #include <algorithm>
#include <cstdio>
#include <vector>
int main() {
int N, M, X, Y;
scanf("%d %d %d %d", &N, &M, &X, &Y);
std::vector<int> x(N);
std::vector<int> y(N);
int xmax = -100;
int ymin = 100;
for (int i = 0; i < N; i++) {
scanf("%d", &x[i]);
if (x[i] > xmax)
xmax = x[i];
}
for (int i = 0; i < M; i++) {
scanf("%d", &y[i]);
if (y[i] < ymin)
ymin = y[i];
}
X = std::max(X, xmax);
Y = std::min(Y, ymin);
if (X < Y)
printf("No War");
else
printf("War");
} | #include <algorithm>
#include <cstdio>
#include <vector>
int main() {
int N, M, X, Y;
scanf("%d %d %d %d", &N, &M, &X, &Y);
std::vector<int> x(N);
std::vector<int> y(M);
int xmax = -100;
int ymin = 100;
for (int i = 0; i < N; i++) {
scanf("%d", &x[i]);
if (x[i] > xmax)
xmax = x[i];
}
for (int i = 0; i < M; i++) {
scanf("%d", &y[i]);
if (y[i] < ymin)
ymin = y[i];
}
X = std::max(X, xmax);
Y = std::min(Y, ymin);
if (X < Y)
printf("No War");
else
printf("War");
} | replace | 8 | 9 | 8 | 9 | 0 | |
p03251 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, M, X, Y;
cin >> N >> M >> X >> Y;
vector<int> x(N + 1);
vector<int> y(M + 1);
x[N] = X;
y[M] = Y;
for (int i = 0; i < N; i++) {
cin >> x[i] >> y[i];
}
sort(x.begin(), x.end());
sort(y.begin(), y.end());
if (x[N] < y[0])
cout << "No War";
else
cout << "War";
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, M, X, Y;
cin >> N >> M >> X >> Y;
vector<int> x(N + 1);
vector<int> y(M + 1);
x[N] = X;
y[M] = Y;
for (int i = 0; i < N; i++)
cin >> x[i];
for (int i = 0; i < M; i++)
cin >> y[i];
sort(x.begin(), x.end());
sort(y.begin(), y.end());
if (x[N] < y[0])
cout << "No War";
else
cout << "War";
} | replace | 10 | 13 | 10 | 14 | 0 | |
p03251 | C++ | Runtime Error | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define repe(i, n) for (int i = 0; i <= n; ++i)
#define repr(i, n) for (int i = n - 1; i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
using namespace std;
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> bool chmin(T &a, const T &b) {
if (b < a) {
a = b;
return 1;
}
return 0;
}
template <class T> using V = vector<T>;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1000000007;
const ll MAX = 510000;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
// 二項係数計算
long long COM(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
double temp(int t, int h) {
double s = t - h * 0.006;
return s;
}
int main() {
int n, m, x, y;
cin >> n >> m >> x >> y;
vector<int> X(n);
vector<int> Y(n);
rep(i, n) { cin >> X[i]; }
rep(i, m) { cin >> Y[i]; }
for (int z = x + 1; z <= y; ++z) {
bool bx = true, by = true;
rep(i, n) {
if (X[i] >= z) {
bx = false;
}
}
rep(i, m) {
if (Y[i] < z) {
by = false;
}
}
if (bx == true && by == true) {
cout << "No War"
<< "\n";
return 0;
}
}
cout << "War"
<< "\n";
}
| #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define repe(i, n) for (int i = 0; i <= n; ++i)
#define repr(i, n) for (int i = n - 1; i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
using namespace std;
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> bool chmin(T &a, const T &b) {
if (b < a) {
a = b;
return 1;
}
return 0;
}
template <class T> using V = vector<T>;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1000000007;
const ll MAX = 510000;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
// 二項係数計算
long long COM(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
double temp(int t, int h) {
double s = t - h * 0.006;
return s;
}
int main() {
int n, m, x, y;
cin >> n >> m >> x >> y;
vector<int> X(n);
vector<int> Y(m);
rep(i, n) { cin >> X[i]; }
rep(i, m) { cin >> Y[i]; }
for (int z = x + 1; z <= y; ++z) {
bool bx = true, by = true;
rep(i, n) {
if (X[i] >= z) {
bx = false;
}
}
rep(i, m) {
if (Y[i] < z) {
by = false;
}
}
if (bx == true && by == true) {
cout << "No War"
<< "\n";
return 0;
}
}
cout << "War"
<< "\n";
}
| replace | 58 | 59 | 58 | 59 | 0 | |
p03251 | C++ | Runtime Error | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n, m, x, y;
cin >> n >> m >> x >> y;
vector<int> v(n);
vector<int> w(m);
for (int i = 0; i < n; i++) {
cin >> v[i];
}
for (int i = 0; i < m; i++) {
cin >> w[i];
}
sort(v.begin(), v.end());
sort(w.begin(), v.end());
if (v[n - 1] < w[0]) {
cout << "No War" << endl;
} else {
cout << "War" << endl;
}
} | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n, m, x, y;
cin >> n >> m >> x >> y;
vector<int> v(n);
vector<int> w(m);
for (int i = 0; i < n; i++) {
cin >> v[i];
}
for (int i = 0; i < m; i++) {
cin >> w[i];
}
sort(v.begin(), v.end());
sort(w.begin(), w.end());
if (v[n - 1] < w[0] && v[n - 1] < y && x < w[0]) {
cout << "No War" << endl;
} else {
cout << "War" << endl;
}
} | replace | 17 | 19 | 17 | 19 | -11 | |
p03251 | C++ | Runtime Error | #include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
// #define int long
signed main() {
int N, M, X, Y;
cin >> N >> M >> X >> Y;
vector<int> x(N), y(N);
for (int i = 0; i < N; i++)
cin >> x[i];
for (int i = 0; i < M; i++)
cin >> y[i];
int max_x = -100, min_y = 100;
for (int i = 0; i < N; i++)
if (max_x < x[i])
max_x = x[i];
for (int i = 0; i < M; i++)
if (min_y > y[i])
min_y = y[i];
if (Y - X >= 1 && min_y - max_x >= 1 && min_y - X >= 1 && Y - max_x >= 1)
cout << "No War";
else
cout << "War";
} | #include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
// #define int long
signed main() {
int N, M, X, Y;
cin >> N >> M >> X >> Y;
vector<int> x(N), y(M);
for (int i = 0; i < N; i++)
cin >> x[i];
for (int i = 0; i < M; i++)
cin >> y[i];
int max_x = -100, min_y = 100;
for (int i = 0; i < N; i++)
if (max_x < x[i])
max_x = x[i];
for (int i = 0; i < M; i++)
if (min_y > y[i])
min_y = y[i];
if (Y - X >= 1 && min_y - max_x >= 1 && min_y - X >= 1 && Y - max_x >= 1)
cout << "No War";
else
cout << "War";
} | replace | 12 | 13 | 12 | 13 | 0 | |
p03251 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, M, X, Y;
cin >> N >> M >> X >> Y;
vector<int> x(N), y(N);
for (int i = 0; i < N; i++) {
cin >> x.at(i);
}
for (int i = 0; i < M; i++) {
cin >> y.at(i);
}
int count = 0;
for (int i = X + 1; i <= Y; i++) {
for (int j = 0; j < N; j++) {
if (x.at(j) >= i) {
count++;
break;
}
}
for (int k = 0; k < M; k++) {
if (y.at(k) < i) {
count++;
break;
}
}
if (count == 0) {
cout << "No War" << endl;
return 0;
}
count = 0;
}
cout << "War" << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, M, X, Y;
cin >> N >> M >> X >> Y;
vector<int> x(N), y(M);
for (int i = 0; i < N; i++) {
cin >> x.at(i);
}
for (int i = 0; i < M; i++) {
cin >> y.at(i);
}
int count = 0;
for (int i = X + 1; i <= Y; i++) {
for (int j = 0; j < N; j++) {
if (x.at(j) >= i) {
count++;
break;
}
}
for (int k = 0; k < M; k++) {
if (y.at(k) < i) {
count++;
break;
}
}
if (count == 0) {
cout << "No War" << endl;
return 0;
}
count = 0;
}
cout << "War" << endl;
return 0;
} | replace | 5 | 6 | 5 | 6 | 0 | |
p03251 | C++ | Runtime Error | #include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
using ll = long long int;
const ll mod = 1e9 + 7;
#define rep(i, a, b) for (int i = a; i < b; i++)
int main() {
int n, m, X, Y;
cin >> n >> m >> X >> Y;
int xmax = -100, ymin = 100;
vector<int> x(n), y(n);
rep(i, 0, n) {
cin >> x[i];
xmax = max(xmax, x[i]);
}
rep(i, 0, m) {
cin >> y[i];
ymin = min(ymin, y[i]);
}
if (X >= ymin || Y <= xmax || ymin <= xmax)
cout << "War" << endl;
else
cout << "No War" << endl;
return 0;
} | #include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
using ll = long long int;
const ll mod = 1e9 + 7;
#define rep(i, a, b) for (int i = a; i < b; i++)
int main() {
int n, m, X, Y;
cin >> n >> m >> X >> Y;
int xmax = -100, ymin = 100;
vector<int> x(n), y(m);
rep(i, 0, n) {
cin >> x[i];
xmax = max(xmax, x[i]);
}
rep(i, 0, m) {
cin >> y[i];
ymin = min(ymin, y[i]);
}
if (X >= ymin || Y <= xmax || ymin <= xmax)
cout << "War" << endl;
else
cout << "No War" << endl;
return 0;
} | replace | 25 | 26 | 25 | 26 | 0 | |
p03251 | C++ | Runtime Error | #include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#define y0 qvya13579
#define y1 qvyb24680
#define j0 qvja13579
#define j1 qvjb24680
#define next qvne13579xt
#define prev qvpr13579ev
#define INF 1000000007
#define PI acos(-1.0)
#define endl "\n"
#define IOS \
cin.tie(0); \
ios::sync_with_stdio(false)
#define MP_ make_pair
#define PB_ push_back
#define FIR first
#define SEC second
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP_R(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define FOR(i, m, n) for (int i = ((int)(m)); i < (int)(n); ++i)
#define FOR_R(i, m, n) for (int i = ((int)(m)-1); i >= (int)(n); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SIZ(x) ((int)(x).size())
typedef long long int lli;
using namespace std;
int ctoi(char c) {
if (c >= '0' and c <= '9') {
return (int)(c - '0');
}
return -1;
}
int main() {
// IOS; /* making cin faster */
int N, M, X, Y;
scanf("%d%d%d%d", &N, &M, &X, &Y);
vector<int> x(N);
vector<int> y(N);
REP(i, N) { scanf("%d", &x[i]); }
REP(i, M) { scanf("%d", &y[i]); }
int flag_peace = 0;
int flag_val;
FOR(Z, X + 1, Y + 1) {
flag_val = 1;
REP(i, N) {
if (x[i] >= Z) {
flag_val = 0;
break;
}
}
REP(i, M) {
if (y[i] < Z) {
flag_val = 0;
break;
}
}
if (flag_val) {
flag_peace = 1;
break;
}
}
if (flag_peace) {
printf("No War\n");
} else {
printf("War\n");
}
}
| #include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#define y0 qvya13579
#define y1 qvyb24680
#define j0 qvja13579
#define j1 qvjb24680
#define next qvne13579xt
#define prev qvpr13579ev
#define INF 1000000007
#define PI acos(-1.0)
#define endl "\n"
#define IOS \
cin.tie(0); \
ios::sync_with_stdio(false)
#define MP_ make_pair
#define PB_ push_back
#define FIR first
#define SEC second
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP_R(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define FOR(i, m, n) for (int i = ((int)(m)); i < (int)(n); ++i)
#define FOR_R(i, m, n) for (int i = ((int)(m)-1); i >= (int)(n); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SIZ(x) ((int)(x).size())
typedef long long int lli;
using namespace std;
int ctoi(char c) {
if (c >= '0' and c <= '9') {
return (int)(c - '0');
}
return -1;
}
int main() {
// IOS; /* making cin faster */
int N, M, X, Y;
scanf("%d%d%d%d", &N, &M, &X, &Y);
vector<int> x(N);
vector<int> y(M);
REP(i, N) { scanf("%d", &x[i]); }
REP(i, M) { scanf("%d", &y[i]); }
int flag_peace = 0;
int flag_val;
FOR(Z, X + 1, Y + 1) {
flag_val = 1;
REP(i, N) {
if (x[i] >= Z) {
flag_val = 0;
break;
}
}
REP(i, M) {
if (y[i] < Z) {
flag_val = 0;
break;
}
}
if (flag_val) {
flag_peace = 1;
break;
}
}
if (flag_peace) {
printf("No War\n");
} else {
printf("War\n");
}
}
| replace | 58 | 59 | 58 | 59 | 0 | |
p03251 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int x, y, n, m;
cin >> x >> y >> n >> m;
vector<int> vecx(n + 1), vecy(m + 1);
vecx.at(0) = x;
vecy.at(0) = y;
for (int i = 0; i < n; i++) {
cin >> vecx.at(i + 1);
}
for (int i = 0; i < m; i++) {
cin >> vecy.at(i + 1);
}
sort(vecx.begin(), vecx.end());
sort(vecy.begin(), vecy.end());
if (vecx.at(n) + 1 <= vecy.at(0)) {
cout << "No War" << endl;
} else {
cout << "War" << endl;
}
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int x, y, n, m;
cin >> n >> m >> x >> y;
vector<int> vecx(n + 1), vecy(m + 1);
vecx.at(0) = x;
vecy.at(0) = y;
for (int i = 0; i < n; i++) {
cin >> vecx.at(i + 1);
}
for (int i = 0; i < m; i++) {
cin >> vecy.at(i + 1);
}
sort(vecx.begin(), vecx.end());
sort(vecy.begin(), vecy.end());
if (vecx.at(n) + 1 <= vecy.at(0)) {
cout << "No War" << endl;
} else {
cout << "War" << endl;
}
}
| replace | 5 | 6 | 5 | 6 | 0 | |
p03251 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
#include <stdio.h>
#define INF 1e18
#define REP(i, n) for (int i = 0; i < n; i++)
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = " << x << endl
const double PI =
3.141592653589793238462643383279502884197169399375105820974944;
typedef long long ll;
using namespace std;
void solve() {
int N, M, X, Y;
cin >> N >> M >> X >> Y;
vector<int> x(N), y(M);
REP(i, N) cin >> x[i];
REP(i, M) cin >> y[i];
int z = X + 1;
bool ans = false;
while (z <= Y) {
bool ok = true;
REP(i, N) {
if (x[i] < z) {
continue;
} else {
ok = false;
}
}
REP(i, M) {
if (y[i] >= z) {
continue;
} else {
ok = false;
}
}
if (ok) {
ans = true;
break;
}
}
if (ans) {
print("No War");
} else {
print("War");
}
}
signed main() { solve(); }
| #include <bits/stdc++.h>
#include <stdio.h>
#define INF 1e18
#define REP(i, n) for (int i = 0; i < n; i++)
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = " << x << endl
const double PI =
3.141592653589793238462643383279502884197169399375105820974944;
typedef long long ll;
using namespace std;
void solve() {
int N, M, X, Y;
cin >> N >> M >> X >> Y;
vector<int> x(N), y(M);
REP(i, N) cin >> x[i];
REP(i, M) cin >> y[i];
int z = X + 1;
bool ans = false;
while (z <= Y) {
bool ok = true;
REP(i, N) {
if (x[i] < z) {
continue;
} else {
ok = false;
}
}
REP(i, M) {
if (y[i] >= z) {
continue;
} else {
ok = false;
}
}
if (ok) {
ans = true;
break;
}
z++;
}
if (ans) {
print("No War");
} else {
print("War");
}
}
signed main() { solve(); }
| insert | 45 | 45 | 45 | 46 | TLE | |
p03251 | Python | Runtime Error | n, m, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
if max(x, X) < min(y, Y):
print("No War")
else:
print("War")
| n, m, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
if max(x + [X]) < min(y + [Y]):
print("No War")
else:
print("War")
| replace | 4 | 5 | 4 | 5 | TypeError: '>' not supported between instances of 'int' and 'list' | Traceback (most recent call last):
File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03251/Python/s487114190.py", line 5, in <module>
if max(x, X) < min(y, Y):
TypeError: '>' not supported between instances of 'int' and 'list'
|
p03251 | Python | Runtime Error | #!/usr/bin/env python3
import sys
try:
from typing import List
except ImportError:
pass
def solve(N: int, M: int, X: int, Y: int, x: "List[int]", y: "List[int]"):
xs = {X, *x}
ys = {Y, *y}
x1 = min(xs)
x2 = max(xs)
y1 = min(ys)
y2 = max(ys)
print("No War" if (x2 < y1 or y2 < x1) else "War")
def main():
def iterate_tokens():
for line in sys.stdin:
for word in line.split():
yield word
tokens = iterate_tokens()
N = int(next(tokens)) # type: int
M = int(next(tokens)) # type: int
X = int(next(tokens)) # type: int
Y = int(next(tokens)) # type: int
x = [int(next(tokens)) for _ in range(N)] # type: "List[int]"
y = [int(next(tokens)) for _ in range(M)] # type: "List[int]"
solve(N, M, X, Y, x, y)
if __name__ == "__main__":
main()
| #!/usr/bin/env python3
import sys
try:
from typing import List
except ImportError:
pass
def solve(N: int, M: int, X: int, Y: int, x: "List[int]", y: "List[int]"):
xs = set(x)
xs.add(X)
ys = set(y)
ys.add(Y)
x1 = min(xs)
x2 = max(xs)
y1 = min(ys)
y2 = max(ys)
print("No War" if (x2 < y1 or y2 < x1) else "War")
def main():
def iterate_tokens():
for line in sys.stdin:
for word in line.split():
yield word
tokens = iterate_tokens()
N = int(next(tokens)) # type: int
M = int(next(tokens)) # type: int
X = int(next(tokens)) # type: int
Y = int(next(tokens)) # type: int
x = [int(next(tokens)) for _ in range(N)] # type: "List[int]"
y = [int(next(tokens)) for _ in range(M)] # type: "List[int]"
solve(N, M, X, Y, x, y)
if __name__ == "__main__":
main()
| replace | 10 | 12 | 10 | 14 | 0 | |
p03251 | Python | Runtime Error | # max min
n, m, x, y = map(int, input().split())
xs = max(list(map(int, input().split())))
ys = min(list(map(int, input().split())))
print("No War" if xs + 1 < ys else "War")
# max min
n, m, x, y = map(int, input().split())
xs = max(list(map(int, input().split())))
ys = min(list(map(int, input().split())))
print("No War" if xs + 1 <= ys else "War")
| # max min
n, m, x, y = map(int, input().split())
xs = max(list(map(int, input().split())))
ys = min(list(map(int, input().split())))
print("No War" if xs < ys and x <= xs and ys <= y else "War")
| replace | 4 | 10 | 4 | 6 | EOFError: EOF when reading a line | Traceback (most recent call last):
File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03251/Python/s312526263.py", line 7, in <module>
n, m, x, y = map(int, input().split())
EOFError: EOF when reading a line
|
p03251 | C++ | Runtime Error | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n, m, x, y;
cin >> n >> m >> x >> y;
vector<int> X(n), Y(n);
for (int i = 0; i < n; i++)
cin >> X[i];
for (int i = 0; i < m; i++)
cin >> Y[i];
int xmax = x, ymin = y;
for (int i = 0; i < n; i++) {
xmax = max(xmax, X[i]);
}
for (int i = 0; i < m; i++) {
ymin = min(ymin, Y[i]);
}
for (int i = -200; i < 200; i++) {
if (xmax < i && ymin >= i) {
cout << "No War" << endl;
return 0;
}
}
cout << "War" << endl;
} | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n, m, x, y;
cin >> n >> m >> x >> y;
vector<int> X(n), Y(m);
for (int i = 0; i < n; i++)
cin >> X[i];
for (int i = 0; i < m; i++)
cin >> Y[i];
int xmax = x, ymin = y;
for (int i = 0; i < n; i++) {
xmax = max(xmax, X[i]);
}
for (int i = 0; i < m; i++) {
ymin = min(ymin, Y[i]);
}
for (int i = -200; i < 200; i++) {
if (xmax < i && ymin >= i) {
cout << "No War" << endl;
return 0;
}
}
cout << "War" << endl;
} | replace | 8 | 9 | 8 | 9 | 0 | |
p03251 | C++ | Runtime Error | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
int X, Y;
cin >> X >> Y;
vector<int> x(N);
vector<int> y(N);
for (int n = 0; n < N; n++) {
cin >> x[n];
}
for (int m = 0; m < M; m++) {
cin >> y[m];
}
sort(x.begin(), x.end());
sort(y.begin(), y.end());
if (X < y[0] && y[0] <= Y && x[N - 1] < y[0]) {
cout << "No War" << endl;
} else {
cout << "War" << endl;
}
return 0;
} | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
int X, Y;
cin >> X >> Y;
vector<int> x(N);
vector<int> y(M);
for (int n = 0; n < N; n++) {
cin >> x[n];
}
for (int m = 0; m < M; m++) {
cin >> y[m];
}
sort(x.begin(), x.end());
sort(y.begin(), y.end());
if (X < y[0] && y[0] <= Y && x[N - 1] < y[0]) {
cout << "No War" << endl;
} else {
cout << "War" << endl;
}
return 0;
} | replace | 12 | 13 | 12 | 13 | 0 | |
p03252 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define fastio() ios::sync_with_stdio(0), cin.tie(0);
#define REP(i, n) for (int i = 0; i < (n); i++)
int main() {
fastio();
string S, T;
cin >> S >> T;
int a[26] =
{
0,
},
b[26] = {
0,
};
REP(i, S.size()) a[S[i] - 'a']++;
REP(i, T.size()) b[T[i] - 'a']++;
bool x = false;
REP(i, S.size()) x |= (a[i] != b[i]);
x ? cout << "No" : cout << "Yes";
return 0;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define fastio() ios::sync_with_stdio(0), cin.tie(0);
#define REP(i, n) for (int i = 0; i < (n); i++)
int main() {
fastio();
string S, T;
cin >> S >> T;
int a[26] =
{
0,
},
b[26] = {
0,
};
REP(i, S.size()) a[S[i] - 'a']++;
REP(i, T.size()) b[T[i] - 'a']++;
bool x = false;
sort(a, a + 26);
sort(b, b + 26);
REP(i, 26) x |= (a[i] != b[i]);
x ? cout << "No" : cout << "Yes";
return 0;
} | replace | 21 | 22 | 21 | 24 | 0 | |
p03252 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
string S[2];
cin >> S[1] >> S[2];
int S_[2][200001];
int N = (int)S[1].size();
for (int i = 0; i < 2; i++) {
string a = "";
for (int j = 0; j < N; j++) {
int n = a.size();
int p = 0;
while (p < n && a[p] != S[i][j])
p++;
S_[i][j] = p;
if (p == n)
a += S[i][j];
}
}
for (int i = 0; i < N; i++) {
if (S_[0][i] != S_[1][i]) {
cout << "No" << endl;
return 0;
}
}
cout << "Yes" << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
string S[2];
cin >> S[0] >> S[1];
int S_[2][200001];
int N = (int)S[1].size();
for (int i = 0; i < 2; i++) {
string a = "";
for (int j = 0; j < N; j++) {
int n = a.size();
int p = 0;
while (p < n && a[p] != S[i][j])
p++;
S_[i][j] = p;
if (p == n)
a += S[i][j];
}
}
for (int i = 0; i < N; i++) {
if (S_[0][i] != S_[1][i]) {
cout << "No" << endl;
return 0;
}
}
cout << "Yes" << endl;
}
| replace | 4 | 5 | 4 | 5 | -11 | |
p03252 | C++ | Runtime Error | #include <algorithm>
#include <iostream>
#include <string.h>
#include <vector>
using namespace std;
const int MAXN = (int)1e5 + 1;
struct Node {
vector<int> node;
};
bool cmp(Node x, Node y) {
if (x.node.size() != y.node.size())
return x.node.size() < y.node.size();
else {
for (int i = 0; i < x.node.size(); ++i) {
if (x.node[i] != y.node[i])
return x.node[i] < y.node[i];
}
}
}
Node a[26], b[26];
char s[MAXN], t[MAXN];
bool solve() {
int n = strlen(s);
for (int i = 0; i < n; ++i) {
a[s[i] - 'a'].node.push_back(i);
}
for (int i = 0; i < n; ++i) {
b[t[i] - 'a'].node.push_back(i);
}
for (int i = 0; i < 26; ++i) {
sort(a[i].node.begin(), a[i].node.end());
sort(b[i].node.begin(), b[i].node.end());
}
sort(a, a + 26, cmp);
sort(b, b + 26, cmp);
for (int i = 0; i < 26; ++i) {
if (a[i].node.size() != b[i].node.size())
return false;
for (int j = 0; j < a[i].node.size(); ++j) {
if (a[i].node[j] != b[i].node[j])
return false;
}
}
return true;
}
int main() {
scanf("%s", s);
scanf("%s", t);
if (solve())
puts("Yes");
else
puts("No");
return 0;
}
| #include <algorithm>
#include <iostream>
#include <string.h>
#include <vector>
using namespace std;
const int MAXN = (int)2e5 + 1;
struct Node {
vector<int> node;
};
bool cmp(Node x, Node y) {
if (x.node.size() != y.node.size())
return x.node.size() < y.node.size();
else {
for (int i = 0; i < x.node.size(); ++i) {
if (x.node[i] != y.node[i])
return x.node[i] < y.node[i];
}
}
}
Node a[26], b[26];
char s[MAXN], t[MAXN];
bool solve() {
int n = strlen(s);
for (int i = 0; i < n; ++i) {
a[s[i] - 'a'].node.push_back(i);
}
for (int i = 0; i < n; ++i) {
b[t[i] - 'a'].node.push_back(i);
}
for (int i = 0; i < 26; ++i) {
sort(a[i].node.begin(), a[i].node.end());
sort(b[i].node.begin(), b[i].node.end());
}
sort(a, a + 26, cmp);
sort(b, b + 26, cmp);
for (int i = 0; i < 26; ++i) {
if (a[i].node.size() != b[i].node.size())
return false;
for (int j = 0; j < a[i].node.size(); ++j) {
if (a[i].node[j] != b[i].node[j])
return false;
}
}
return true;
}
int main() {
scanf("%s", s);
scanf("%s", t);
if (solve())
puts("Yes");
else
puts("No");
return 0;
}
| replace | 7 | 8 | 7 | 8 | 0 | |
p03252 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
map<char, int> s;
char s1[505], s2[505];
int main() {
scanf("%s", s1);
scanf("%s", s2);
int t = strlen(s1);
for (register int i = 0; i < t; i++)
if (s[s1[i]] == 0)
s[s1[i]] = s2[i] - 'a' + 1;
else if (s[s1[i]] != s2[i] - 'a' + 1) {
printf("No\n");
exit(0);
}
s.clear();
for (register int i = 0; i < t; i++)
if (s[s2[i]] == 0)
s[s2[i]] = s1[i] - 'a' + 1;
else if (s[s2[i]] != s1[i] - 'a' + 1) {
printf("No\n");
exit(0);
}
printf("Yes\n");
return 0;
} | #include <bits/stdc++.h>
using namespace std;
map<char, int> s;
char s1[200005], s2[200005];
int main() {
scanf("%s", s1);
scanf("%s", s2);
int t = strlen(s1);
for (register int i = 0; i < t; i++)
if (s[s1[i]] == 0)
s[s1[i]] = s2[i] - 'a' + 1;
else if (s[s1[i]] != s2[i] - 'a' + 1) {
printf("No\n");
exit(0);
}
s.clear();
for (register int i = 0; i < t; i++)
if (s[s2[i]] == 0)
s[s2[i]] = s1[i] - 'a' + 1;
else if (s[s2[i]] != s1[i] - 'a' + 1) {
printf("No\n");
exit(0);
}
printf("Yes\n");
return 0;
} | replace | 3 | 4 | 3 | 4 | 0 | |
p03252 | C++ | Runtime Error | #include <algorithm>
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
int main() {
string s, t;
cin >> s >> t;
int n = s.size();
if (n == 1) {
cout << "Yes" << endl;
return 0;
}
vector<char> r1(30);
vector<char> r2(30);
rep(i, n) {
r1[s[i]] = '1';
r2[t[i]] = '1';
}
bool ok = 1;
rep(i, n) {
if (r1[s[i]] == '1')
r1[s[i]] = t[i];
if (r2[t[i]] == '1')
r2[t[i]] = s[i];
if (r1[s[i]] != '1' && r1[s[i]] != t[i])
ok = 0;
if (r2[t[i]] != '1' && r2[t[i]] != s[i])
ok = 0;
}
if (ok)
cout << "Yes" << endl;
else
cout << "No" << endl;
}
| #include <algorithm>
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
int main() {
string s, t;
cin >> s >> t;
int n = s.size();
if (n == 1) {
cout << "Yes" << endl;
return 0;
}
char r1[200005];
char r2[200005];
rep(i, n) {
r1[s[i]] = '1';
r2[t[i]] = '1';
}
bool ok = 1;
rep(i, n) {
if (r1[s[i]] == '1')
r1[s[i]] = t[i];
if (r2[t[i]] == '1')
r2[t[i]] = s[i];
if (r1[s[i]] != '1' && r1[s[i]] != t[i])
ok = 0;
if (r2[t[i]] != '1' && r2[t[i]] != s[i])
ok = 0;
}
if (ok)
cout << "Yes" << endl;
else
cout << "No" << endl;
}
| replace | 19 | 21 | 19 | 21 | 0 | |
p03252 | C++ | Time Limit Exceeded | //============================================================================
// Name : abc110c.cpp
// Author :
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <algorithm>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int main() {
string s, t;
cin >> s;
map<char, vector<char>> mp1;
map<char, vector<char>> mp2;
for (int i = 0; i < s.length(); ++i) {
char c;
cin >> c;
t += c;
mp1[c].push_back(s[i]);
mp2[s[i]].push_back(c);
}
for (int i = 0; i < t.length(); ++i) {
static map<char, bool> check;
if (check[t[i]] == true) {
continue;
}
check[t[i]] = true;
vector<char> c1 = mp1[t[i]];
sort(c1.begin(), c1.end());
if (c1[0] != c1[c1.size() - 1]) {
cout << "No" << endl;
return 0;
}
}
for (int i = 0; i < t.length(); ++i) {
static map<char, bool> check;
if (check[s[i]] == true) {
continue;
}
check[t[i]] = true;
vector<char> c2 = mp2[s[i]];
sort(c2.begin(), c2.end());
if (c2[0] != c2[c2.size() - 1]) {
cout << "No" << endl;
return 0;
}
}
cout << "Yes" << endl;
return 0;
}
| //============================================================================
// Name : abc110c.cpp
// Author :
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <algorithm>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int main() {
string s, t;
cin >> s;
map<char, vector<char>> mp1;
map<char, vector<char>> mp2;
for (int i = 0; i < s.length(); ++i) {
char c;
cin >> c;
t += c;
mp1[c].push_back(s[i]);
mp2[s[i]].push_back(c);
}
for (int i = 0; i < t.length(); ++i) {
static map<char, bool> check;
if (check[t[i]] == true) {
continue;
}
check[t[i]] = true;
vector<char> c1 = mp1[t[i]];
sort(c1.begin(), c1.end());
if (c1[0] != c1[c1.size() - 1]) {
cout << "No" << endl;
return 0;
}
}
for (int i = 0; i < t.length(); ++i) {
static map<char, bool> check;
if (check[s[i]] == true) {
continue;
}
check[s[i]] = true;
vector<char> c2 = mp2[s[i]];
sort(c2.begin(), c2.end());
if (c2[0] != c2[c2.size() - 1]) {
cout << "No" << endl;
return 0;
}
}
cout << "Yes" << endl;
return 0;
}
| replace | 54 | 55 | 54 | 55 | TLE | |
p03252 | C++ | Time Limit Exceeded | #pragma region header
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define ld long double
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define vs vector<string>
#define vvs vector<vector<string>>
#define vvvs vector<vector<vector<string>>>
#define vd vector<ld>
#define vvd vector<vector<ld>>
#define vvvd vector<vector<vector<ld>>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vvvb vector<vector<vector<bool>>>
#define pii pair<int, int>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define vvvp vector<vector<vector<pair<int, int>>>>
#define mii map<int, int>
#define vm vector<map<int, int>>
#define vvm vector<map<pair<int, int>>>
#define vvvm vector<vector<vector<map<int, int>>>>
#define all(a) begin(a), end(a)
#define rall(a) rbegin(a), rend(a)
#define lambda(i) [=](auto i)
#define compare(i, j) [=](auto i, auto j)
#define mp make_pair
#define mt make_tuple
#define rep1(i, n) for (decltype(+n) i = 0; i < (n); i++)
#define rrep1(i, n) for (auto i = n - 1; i != static_cast<decltype(i)>(-1); i--)
#define rep2(i, a, b) for (auto i = (a); i < (b); i++)
#define rrep2(i, a, b) for (auto i = b - 1; i >= a; i--)
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define rrep(...) GET_MACRO(__VA_ARGS__, rrep2, rrep1)(__VA_ARGS__)
#define each(i, a) for (auto &&i : (a))
#define split_pair(f, s, p) \
auto f = p.first; \
auto s = p.second
using namespace std;
const int INF = 1e18;
const int MOD = 1e9 + 7;
int mod(int a) { return (a % MOD + MOD) % MOD; }
int m_add(int a, int b) { return (a + b) % MOD; }
int m_add(int a, int b, int c) { return (a + b + c) % MOD; }
int m_sub(int a, int b) { return (a + MOD - b) % MOD; }
int m_mul(int a, int b) { return a * b % MOD; }
int m_mul(int a, int b, int c) { return a * b % MOD * c % MOD; }
int m_bipow(int x, int y) {
if (y == 0)
return 1;
else if (y == 1)
return x % MOD;
else if (y % 2 == 0) {
int z = m_bipow(x, (int)(y / 2));
return m_mul(z, z);
} else {
int z = m_bipow(x, (int)(y / 2));
return m_mul(z, z, x);
}
}
int m_inv(int x) { return m_bipow(x, MOD - 2); }
int m_div(int a, int b) { return m_mul(a, m_inv(b)); }
template <class T> void SORT(T &a) { stable_sort(all(a)); }
template <class T> void RSORT(T &a) { stable_sort(rall(a)); }
template <class T> void rev(T &a) { reverse(rall(a)); }
template <class T> void uniq(T &a) { a.erase(unique(all(a)), end(a)); }
template <class T> auto min_of(T a) { return *min_element(all(a)); }
template <class T> auto max_of(T a) { return *max_element(all(a)); }
template <class T> int sum_of(T a) { return accumulate(all(a), 0ll); }
template <class T, class U> auto sum_of(T a, U init) {
return accumulate(all(a), init);
}
template <class T, class U> int count_of(T a, U i) { return count(all(a), i); }
template <class T> T cum(T v) {
T u(sz(v));
partial_sum(all(v), begin(u));
return u;
}
template <class T, class U> int lower_index(T a, U i) {
return lower_bound(all(a), i) - begin(a);
} // use member func for set
template <class T, class U> int upper_index(T a, U i) {
return upper_bound(all(a), i) - begin(a);
}
template <class T, class U> bool binary(T a, U i) {
return binary_search(all(a), i);
}
template <class T, class U> bool exists(T a, U i) {
return find(all(a), i) != end(a);
}
template <class T> int sz(T a) { return a.size(); };
template <class T> void COUT(T x) { cout << x << endl; }
template <class T> bool amin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> bool amax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <class T> vector<pair<T, int>> indexed_vector(vector<T> v) {
int n = sz(v);
vector<pair<T, int>> w(n);
for (int i = 0; i < n; i++)
w[i] = make_pair(v[i], i);
return w;
}
template <class T, class S> vector<pair<T, S>> zip(vector<T> v, vector<S> w) {
int n = min(sz(v), sz(w));
vector<pair<T, S>> x(n);
for (int i = 0; i < n; i++)
x[i] = make_pair(v[i], w[i]);
return x;
}
template <class T, class S>
pair<vector<T>, vector<S>> unzip(vector<pair<T, S>> v) {
int n = sz(v);
auto w = make_pair(vector<T>(n), vector<S>(n));
for (int i = 0; i < n; i++) {
w.first[i] = v[i].first;
w.second[i] = v[i].second;
}
return w;
}
vs split(const string &s, string d) {
vs elms;
size_t offset = 0, d_size = d.size();
while (true) {
size_t next = s.find_first_of(d, offset);
if (next == string::npos) {
elms.push_back(s.substr(offset));
return elms;
}
elms.push_back(s.substr(offset, next - offset));
offset = next + d_size;
}
}
vs split(const string &s, char d) { return split(s, string(1, d)); }
string join(const vs &v, const string d = "") {
string s;
if (!v.empty()) {
s += v[0];
for (size_t i = 1, c = v.size(); i < c; ++i) {
if (!d.empty())
s += d;
s += v[i];
}
}
return s;
}
string join(const vs &v, const char d) { return join(v, string(1, d)); }
string pad_left(string s, int width, char filler = '0') {
int n = sz(s);
if (n > width)
return s.substr(n - width);
return string(width - n, filler) + s;
}
vi divisors(int n) {
vi ret;
for (int i = 1; i * i <= n; i++) {
if (n % i == 0) {
ret.push_back(i);
if (i * i != n)
ret.push_back(n / i);
}
}
SORT(ret);
return ret;
}
mii prime_factors(int n) {
mii ret;
for (int i = 2; i * i <= n; i++) {
while (n % i == 0) {
ret[i]++;
n /= i;
}
}
if (n != 1)
ret[n]++;
return ret;
}
int ceil_div(int x, int y) { return (x - 1) / y + 1; }
struct union_find {
vi data;
union_find(int size) : data(size, -1) {}
bool union_set(int x, int y) {
x = root(x);
y = root(y);
if (x != y) {
if (data[y] < data[x])
swap(x, y);
data[x] += data[y];
data[y] = x;
}
return x != y;
}
bool find_set(int x, int y) { return root(x) == root(y); }
int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
int size(int x) { return -data[root(x)]; }
};
// struct combination {
// vi fact, ifact;
// combination(int n): fact(n + 1), ifact(n + 1) {
// assert(n < MOD);
// fact[0] = 1;
// for (int i = 1; i <= n; ++i) fact[i] = m_mul(fact[i - 1], i);
// ifact[n] = m_inv(fact[n]);
// for (int i = n; i >= 1; --i) ifact[i-1] = m_mul(ifact[i], i);
// }
// int operator()(int n, int k) {
// if (k < 0 || k > n) return 0;
// return m_mul(fact[n], ifact[k], ifact[n - k]);
// }
// } comb(200001);
#pragma endregion header
// MOD = 1e9 + 7;
const string YES = "Yes";
const string NO = "No";
void solve(string s, string t) {
int index = 1;
vi sv('z' + 1);
vi tv('z' + 1);
rep(i, sz(s)) {
if (sv[s[i]] == 0) {
if (tv[t[i]] > 0) {
COUT(NO);
return;
}
sv[s[i]] = index;
tv[t[i]] = index;
index++;
}
if (sv[s[i]] != tv[t[i]]) {
COUT(NO);
return;
}
}
COUT(YES);
}
#pragma region main
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout << fixed << setprecision(15);
string s;
cin >> s;
string t;
cin >> t;
solve(s, t);
}
#pragma endregion main
| #pragma region header
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define ld long double
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define vs vector<string>
#define vvs vector<vector<string>>
#define vvvs vector<vector<vector<string>>>
#define vd vector<ld>
#define vvd vector<vector<ld>>
#define vvvd vector<vector<vector<ld>>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vvvb vector<vector<vector<bool>>>
#define pii pair<int, int>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define vvvp vector<vector<vector<pair<int, int>>>>
#define mii map<int, int>
#define vm vector<map<int, int>>
#define vvm vector<map<pair<int, int>>>
#define vvvm vector<vector<vector<map<int, int>>>>
#define all(a) begin(a), end(a)
#define rall(a) rbegin(a), rend(a)
#define lambda(i) [=](auto i)
#define compare(i, j) [=](auto i, auto j)
#define mp make_pair
#define mt make_tuple
#define rep1(i, n) for (decltype(+n) i = 0; i < (n); i++)
#define rrep1(i, n) for (auto i = n - 1; i != static_cast<decltype(i)>(-1); i--)
#define rep2(i, a, b) for (auto i = (a); i < (b); i++)
#define rrep2(i, a, b) for (auto i = b - 1; i >= a; i--)
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define rrep(...) GET_MACRO(__VA_ARGS__, rrep2, rrep1)(__VA_ARGS__)
#define each(i, a) for (auto &&i : (a))
#define split_pair(f, s, p) \
auto f = p.first; \
auto s = p.second
using namespace std;
const int INF = 1e18;
const int MOD = 1e9 + 7;
int mod(int a) { return (a % MOD + MOD) % MOD; }
int m_add(int a, int b) { return (a + b) % MOD; }
int m_add(int a, int b, int c) { return (a + b + c) % MOD; }
int m_sub(int a, int b) { return (a + MOD - b) % MOD; }
int m_mul(int a, int b) { return a * b % MOD; }
int m_mul(int a, int b, int c) { return a * b % MOD * c % MOD; }
int m_bipow(int x, int y) {
if (y == 0)
return 1;
else if (y == 1)
return x % MOD;
else if (y % 2 == 0) {
int z = m_bipow(x, (int)(y / 2));
return m_mul(z, z);
} else {
int z = m_bipow(x, (int)(y / 2));
return m_mul(z, z, x);
}
}
int m_inv(int x) { return m_bipow(x, MOD - 2); }
int m_div(int a, int b) { return m_mul(a, m_inv(b)); }
template <class T> void SORT(T &a) { stable_sort(all(a)); }
template <class T> void RSORT(T &a) { stable_sort(rall(a)); }
template <class T> void rev(T &a) { reverse(rall(a)); }
template <class T> void uniq(T &a) { a.erase(unique(all(a)), end(a)); }
template <class T> auto min_of(T a) { return *min_element(all(a)); }
template <class T> auto max_of(T a) { return *max_element(all(a)); }
template <class T> int sum_of(T a) { return accumulate(all(a), 0ll); }
template <class T, class U> auto sum_of(T a, U init) {
return accumulate(all(a), init);
}
template <class T, class U> int count_of(T a, U i) { return count(all(a), i); }
template <class T> T cum(T v) {
T u(sz(v));
partial_sum(all(v), begin(u));
return u;
}
template <class T, class U> int lower_index(T a, U i) {
return lower_bound(all(a), i) - begin(a);
} // use member func for set
template <class T, class U> int upper_index(T a, U i) {
return upper_bound(all(a), i) - begin(a);
}
template <class T, class U> bool binary(T a, U i) {
return binary_search(all(a), i);
}
template <class T, class U> bool exists(T a, U i) {
return find(all(a), i) != end(a);
}
template <class T> int sz(T a) { return a.size(); };
template <class T> void COUT(T x) { cout << x << endl; }
template <class T> bool amin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> bool amax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <class T> vector<pair<T, int>> indexed_vector(vector<T> v) {
int n = sz(v);
vector<pair<T, int>> w(n);
for (int i = 0; i < n; i++)
w[i] = make_pair(v[i], i);
return w;
}
template <class T, class S> vector<pair<T, S>> zip(vector<T> v, vector<S> w) {
int n = min(sz(v), sz(w));
vector<pair<T, S>> x(n);
for (int i = 0; i < n; i++)
x[i] = make_pair(v[i], w[i]);
return x;
}
template <class T, class S>
pair<vector<T>, vector<S>> unzip(vector<pair<T, S>> v) {
int n = sz(v);
auto w = make_pair(vector<T>(n), vector<S>(n));
for (int i = 0; i < n; i++) {
w.first[i] = v[i].first;
w.second[i] = v[i].second;
}
return w;
}
vs split(const string &s, string d) {
vs elms;
size_t offset = 0, d_size = d.size();
while (true) {
size_t next = s.find_first_of(d, offset);
if (next == string::npos) {
elms.push_back(s.substr(offset));
return elms;
}
elms.push_back(s.substr(offset, next - offset));
offset = next + d_size;
}
}
vs split(const string &s, char d) { return split(s, string(1, d)); }
string join(const vs &v, const string d = "") {
string s;
if (!v.empty()) {
s += v[0];
for (size_t i = 1, c = v.size(); i < c; ++i) {
if (!d.empty())
s += d;
s += v[i];
}
}
return s;
}
string join(const vs &v, const char d) { return join(v, string(1, d)); }
string pad_left(string s, int width, char filler = '0') {
int n = sz(s);
if (n > width)
return s.substr(n - width);
return string(width - n, filler) + s;
}
vi divisors(int n) {
vi ret;
for (int i = 1; i * i <= n; i++) {
if (n % i == 0) {
ret.push_back(i);
if (i * i != n)
ret.push_back(n / i);
}
}
SORT(ret);
return ret;
}
mii prime_factors(int n) {
mii ret;
for (int i = 2; i * i <= n; i++) {
while (n % i == 0) {
ret[i]++;
n /= i;
}
}
if (n != 1)
ret[n]++;
return ret;
}
int ceil_div(int x, int y) { return (x - 1) / y + 1; }
struct union_find {
vi data;
union_find(int size) : data(size, -1) {}
bool union_set(int x, int y) {
x = root(x);
y = root(y);
if (x != y) {
if (data[y] < data[x])
swap(x, y);
data[x] += data[y];
data[y] = x;
}
return x != y;
}
bool find_set(int x, int y) { return root(x) == root(y); }
int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
int size(int x) { return -data[root(x)]; }
};
// struct combination {
// vi fact, ifact;
// combination(int n): fact(n + 1), ifact(n + 1) {
// assert(n < MOD);
// fact[0] = 1;
// for (int i = 1; i <= n; ++i) fact[i] = m_mul(fact[i - 1], i);
// ifact[n] = m_inv(fact[n]);
// for (int i = n; i >= 1; --i) ifact[i-1] = m_mul(ifact[i], i);
// }
// int operator()(int n, int k) {
// if (k < 0 || k > n) return 0;
// return m_mul(fact[n], ifact[k], ifact[n - k]);
// }
// } comb(200001);
#pragma endregion header
// MOD = 1e9 + 7;
const string YES = "Yes";
const string NO = "No";
void solve(string s, string t) {
int index = 1;
vi sv('z' + 1);
vi tv('z' + 1);
int n = sz(s);
rep(i, n) {
if (sv[s[i]] == 0) {
if (tv[t[i]] > 0) {
COUT(NO);
return;
}
sv[s[i]] = index;
tv[t[i]] = index;
index++;
}
if (sv[s[i]] != tv[t[i]]) {
COUT(NO);
return;
}
}
COUT(YES);
}
#pragma region main
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout << fixed << setprecision(15);
string s;
cin >> s;
string t;
cin >> t;
solve(s, t);
}
#pragma endregion main
| replace | 245 | 246 | 245 | 247 | TLE | |
p03252 | C++ | Runtime Error | #include <cstdio>
#include <cstring>
#include <vector>
using namespace std;
int n, box[30];
char s[100010], t[100010];
int main() {
vector<int> vs[30];
vector<int> vt[30];
scanf("%s", s);
scanf("%s", t);
n = strlen(s);
for (int i = 0; i < n; i++) {
vs[s[i] - 'a'].push_back(i);
vt[t[i] - 'a'].push_back(i);
}
for (int i = 0; i < 30; i++) {
for (int j = 1; j < vs[i].size(); j++)
if (t[vs[i][0]] != t[vs[i][j]]) {
printf("No\n");
return 0;
}
for (int j = 1; j < vt[i].size(); j++)
if (s[vt[i][0]] != s[vt[i][j]]) {
printf("No\n");
return 0;
}
}
printf("Yes\n");
}
| #include <cstdio>
#include <cstring>
#include <vector>
using namespace std;
int n, box[30];
char s[200010], t[200010];
int main() {
vector<int> vs[30];
vector<int> vt[30];
scanf("%s", s);
scanf("%s", t);
n = strlen(s);
for (int i = 0; i < n; i++) {
vs[s[i] - 'a'].push_back(i);
vt[t[i] - 'a'].push_back(i);
}
for (int i = 0; i < 30; i++) {
for (int j = 1; j < vs[i].size(); j++)
if (t[vs[i][0]] != t[vs[i][j]]) {
printf("No\n");
return 0;
}
for (int j = 1; j < vt[i].size(); j++)
if (s[vt[i][0]] != s[vt[i][j]]) {
printf("No\n");
return 0;
}
}
printf("Yes\n");
}
| replace | 5 | 6 | 5 | 6 | 0 | |
p03252 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
int main(void) {
string s, t;
char c1 = -1, c2 = -1;
bool fail = false;
int find_pos = -1;
cin >> s >> t;
while (s != t) {
c1 = c2 = -1;
find_pos = -1;
for (int i = 0; i < s.length(); i++) {
char ch = s[i] - 'a';
char ch_t = t[i] - 'a';
if (s[i] != t[i] && c1 == -1) {
// cout << (char)(ch + 'a') << ">" << (char)(ch_t + 'a') << " " << i <<
// endl;
c1 = ch;
c2 = ch_t;
find_pos = i;
i = -1;
continue;
}
if (c1 == ch) {
s[i] = c2 + 'a';
} else if (c2 == ch) {
s[i] = c1 + 'a';
// cout << i << " : " << find_pos << endl;
if (i < find_pos) {
// cout << "fail\n";
fail = true;
break;
}
}
}
// cout << s << endl;
if (fail) {
break;
}
}
if (fail) {
cout << "No" << endl;
} else {
cout << "Yes" << endl;
}
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main(void) {
string s, t;
char c1 = -1, c2 = -1;
bool fail = false;
int find_pos = -1;
cin >> s >> t;
while (s != t) {
c1 = c2 = -1;
find_pos = -1;
for (int i = 0; i < s.length(); i++) {
char ch = s[i] - 'a';
char ch_t = t[i] - 'a';
if (s[i] != t[i] && c1 == -1) {
// cout << (char)(ch + 'a') << ">" << (char)(ch_t + 'a') << " " << i <<
// endl;
c1 = ch;
c2 = ch_t;
find_pos = i;
i = -1;
continue;
}
if (c1 == ch) {
s[i] = c2 + 'a';
if (i < find_pos) {
// cout << "fail\n";
fail = true;
break;
}
} else if (c2 == ch) {
s[i] = c1 + 'a';
// cout << i << " : " << find_pos << endl;
if (i < find_pos) {
// cout << "fail\n";
fail = true;
break;
}
}
}
// cout << s << endl;
if (fail) {
break;
}
}
if (fail) {
cout << "No" << endl;
} else {
cout << "Yes" << endl;
}
return 0;
} | insert | 29 | 29 | 29 | 34 | TLE | |
p03252 | C++ | Runtime Error | #include <bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;
#define SIZE 100005
char S[SIZE], T[SIZE];
int int_S[SIZE], int_T[SIZE];
int table_S[26], table_T[26];
int main() {
scanf("%s", S);
scanf("%s", T);
for (int i = 0; i < 26; i++) {
table_S[i] = -1;
table_T[i] = -1;
}
int index_S = 0;
int len;
for (len = 0; S[len] != '\0'; len++)
;
for (int i = 0; i < len; i++) {
int ch = S[i] - 'a';
if (table_S[ch] == -1) {
table_S[ch] = index_S++;
}
int_S[i] = table_S[ch];
}
int index_T = 0;
for (int i = 0; i < len; i++) {
int ch = T[i] - 'a';
if (table_T[ch] == -1) {
table_T[ch] = index_T++;
}
int_T[i] = table_T[ch];
}
for (int i = 0; i < len; i++) {
if (int_S[i] != int_T[i]) {
printf("No\n");
return 0;
}
}
printf("Yes\n");
return 0;
}
| #include <bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;
#define SIZE 200005
char S[SIZE], T[SIZE];
int int_S[SIZE], int_T[SIZE];
int table_S[26], table_T[26];
int main() {
scanf("%s", S);
scanf("%s", T);
for (int i = 0; i < 26; i++) {
table_S[i] = -1;
table_T[i] = -1;
}
int index_S = 0;
int len;
for (len = 0; S[len] != '\0'; len++)
;
for (int i = 0; i < len; i++) {
int ch = S[i] - 'a';
if (table_S[ch] == -1) {
table_S[ch] = index_S++;
}
int_S[i] = table_S[ch];
}
int index_T = 0;
for (int i = 0; i < len; i++) {
int ch = T[i] - 'a';
if (table_T[ch] == -1) {
table_T[ch] = index_T++;
}
int_T[i] = table_T[ch];
}
for (int i = 0; i < len; i++) {
if (int_S[i] != int_T[i]) {
printf("No\n");
return 0;
}
}
printf("Yes\n");
return 0;
}
| replace | 9 | 10 | 9 | 10 | 0 | |
p03252 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
// const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
// const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};
int main() {
string s, t;
cin >> s >> t;
REP(i, (int)s.size()) {
if (s[i] != t[i]) {
char a = s[i], b = t[i];
for (int j = 0; j < (int)s.size(); j++) {
if (s[j] == a) {
s[j] = b;
continue;
}
if (s[j] == b) {
s[j] = a;
}
}
}
}
if (s == t)
cout << "Yes" << endl;
else
cout << "No" << endl;
}
| #include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
// const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
// const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};
int main() {
string s, t;
cin >> s >> t;
REP(i, (int)s.size()) {
if (s[i] != t[i]) {
char a = s[i], b = t[i];
for (int j = 0; j < (int)s.size(); j++) {
if (s[j] == a) {
s[j] = b;
continue;
}
if (s[j] == b) {
s[j] = a;
}
if (j < i && s[j] != t[j])
break;
}
}
}
if (s == t)
cout << "Yes" << endl;
else
cout << "No" << endl;
}
| insert | 27 | 27 | 27 | 29 | TLE | |
p03252 | Python | Runtime Error | import sys
import socket
hostname = socket.gethostname()
if hostname == "F551C":
sys.stdin = open("c1.in")
def read_int_list():
return list(map(int, input().split()))
def read_str_list():
return input().split()
def read_int():
return int(input())
def read_str():
return input()
def main():
S = read_str()
T = read_str()
n = len(S)
res = "Yes"
A = [0] * n
B = [0] * n
vu = {}
for i in range(n):
if S[i] in vu:
A[i] = vu[S[i]]
else:
vu[S[i]] = i
A[i] = vu[S[i]]
vu = {}
for i in range(n):
if T[i] in vu:
T[i] = vu[T[i]]
else:
vu[T[i]] = i
B[i] = vu[T[i]]
if A != B:
res = "No"
# for i in range(n):
# for j in range(n):
# if S[i] != S[j] and T[i] == T[j]:
# res = 'No'
# if S[i] == S[j] and T[i] != T[j]:
# res = 'No'
print(res)
main()
| import sys
import socket
hostname = socket.gethostname()
if hostname == "F551C":
sys.stdin = open("c1.in")
def read_int_list():
return list(map(int, input().split()))
def read_str_list():
return input().split()
def read_int():
return int(input())
def read_str():
return input()
def main():
S = read_str()
T = read_str()
n = len(S)
res = "Yes"
A = [0] * n
B = [0] * n
vu = {}
for i in range(n):
if S[i] in vu:
A[i] = vu[S[i]]
else:
vu[S[i]] = i
A[i] = vu[S[i]]
vu = {}
for i in range(n):
if T[i] in vu:
B[i] = vu[T[i]]
else:
vu[T[i]] = i
B[i] = vu[T[i]]
if A != B:
res = "No"
# for i in range(n):
# for j in range(n):
# if S[i] != S[j] and T[i] == T[j]:
# res = 'No'
# if S[i] == S[j] and T[i] != T[j]:
# res = 'No'
print(res)
main()
| replace | 43 | 44 | 43 | 44 | TypeError: 'str' object does not support item assignment | Traceback (most recent call last):
File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03252/Python/s038216513.py", line 61, in <module>
main()
File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03252/Python/s038216513.py", line 44, in main
T[i] = vu[T[i]]
TypeError: 'str' object does not support item assignment
|
p03252 | Python | Time Limit Exceeded | S = input()
T = input()
N = len(S)
pos_S = {c: set() for c in "abcdefghijklmnopqrstuvwxyz"}
[pos_S[S[i]].add(i) for i in range(N)]
pos_T = {c: set() for c in "abcdefghijklmnopqrstuvwxyz"}
[pos_T[T[i]].add(i) for i in range(N)]
if all(pos_S[S[i]] == pos_T[T[i]] for i in range(N)):
print("Yes")
else:
print("No")
| S = input()
T = input()
S_cnt = sorted(S.count(c) for c in set(S))
T_cnt = sorted(T.count(c) for c in set(T))
print("Yes") if S_cnt == T_cnt else print("No")
| replace | 2 | 11 | 2 | 5 | TLE | |
p03252 | Python | Runtime Error | ch_S = input()
ch_T = input()
ind_S = []
ind_T = []
for i in list("abcdefghijklmnopqrstuvwxyz"):
L = [ch_S.find(i)]
ind_S.append(
L,
)
R = [ch_T.find(i)]
ind_T.append(
R,
)
if set(ind_S) == set(ind_T):
print("Yes")
else:
print("No")
| S = input()
T = input()
ls = [0] * 26
lt = [0] * 26
al = [chr(ord("a") + i) for i in range(26)]
for i in range(S.__len__()):
si = al.index(S[i])
ti = al.index(T[i])
ls[si] += 1
lt[ti] += 1
ls.sort()
lt.sort()
if ls == lt:
print("Yes")
else:
print("No")
| replace | 0 | 16 | 0 | 13 | TypeError: unhashable type: 'list' | Traceback (most recent call last):
File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03252/Python/s461485349.py", line 12, in <module>
if set(ind_S) == set(ind_T):
TypeError: unhashable type: 'list'
|
p03252 | Python | Runtime Error | S = input()
T = input()
dic = {}
dic_rev = {}
def solve():
for s, t in zip(S, T):
if t in dic.keys():
if s != dic[t]:
print("No")
return
else:
dic[t] = s
for s, t in zip(S, T):
if t in dic_rev.keys():
if t != dic_rev[s]:
print("No")
return
else:
dic_rev[s] = t
print("Yes")
return
solve()
| S = input()
T = input()
dic = {}
dic_rev = {}
def solve():
for s, t in zip(S, T):
if t in dic.keys():
if s != dic[t]:
print("No")
return
else:
dic[t] = s
for s, t in zip(S, T):
if s in dic_rev.keys():
if t != dic_rev[s]:
print("No")
return
else:
dic_rev[s] = t
print("Yes")
return
solve()
| replace | 16 | 17 | 16 | 17 | KeyError: 'l' | Traceback (most recent call last):
File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03252/Python/s641749726.py", line 27, in <module>
solve()
File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03252/Python/s641749726.py", line 18, in solve
if t != dic_rev[s]:
KeyError: 'l'
|
p03252 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
#define countof(a) (sizeof(a) / sizeof(*a))
#define vi vector<int>
#define vvi vector<vector<int>>
#define vpi vector<pi>
#define pi pair<int, int>
#define fi first
#define se second
#define all(n) n.begin(), n.end()
#define FOR(var, to) for (register s64 var = 0; var < (s64)to; var++)
#define FROMTO(var, from, to) \
for (register s64 var = from; var <= (s64)to; var++)
#define INIT(var, val) FOR(i, countof(var)) var[i] = val
#define INPUT(var) FOR(i, countof(var)) cin >> var[i]
#define INPUT1(var) FOR(i, countof(var)) cin >> var[i], var[i]--
#define SORT(v) qsort(v, countof(v), sizeof(*v), int_less)
#define SORTT(v) qsort(v, countof(v), sizeof(*v), int_greater)
#define QSORT(v, b) qsort(v, countof(v), sizeof(*v), b)
#define MOD 1000000007
#define INF ((1 << 30) - 1)
#define LINF ((1LL << 62) - 1)
typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;
template <int mod> struct ModInt {
int x;
ModInt() : x(0) {}
ModInt(long long y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
ModInt &operator+=(const ModInt &p) {
if ((x += p.x) >= mod)
x -= mod;
return *this;
}
ModInt &operator-=(const ModInt &p) {
if ((x += mod - p.x) >= mod)
x -= mod;
return *this;
}
ModInt &operator*=(const ModInt &p) {
x = (int)(1LL * x * p.x % mod);
return *this;
}
ModInt &operator/=(const ModInt &p) {
*this *= p.inverse();
return *this;
}
ModInt operator-() const { return ModInt(-x); }
ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
bool operator==(const ModInt &p) const { return x == p.x; }
bool operator!=(const ModInt &p) const { return x != p.x; }
operator int() const { return x; }
ModInt operator=(const int p) {
x = p;
return ModInt(*this);
}
ModInt inverse() const {
int a = x, b = mod, u = 1, v = 0, t;
while (b > 0) {
t = a / b;
a -= t * b;
swap(a, b);
u -= t * v;
swap(u, v);
}
return ModInt(u);
}
friend ostream &operator<<(ostream &os, const ModInt<mod> &p) {
return os << p.x;
}
friend istream &operator>>(istream &is, ModInt<mod> &a) {
long long x;
is >> x;
a = ModInt<mod>(x);
return (is);
}
};
typedef ModInt<MOD> mint;
struct UnionFind {
vi data;
UnionFind(int size) : data(size, -1) {}
bool unite(int x, int y) {
x = root(x);
y = root(y);
if (x != y) {
if (data[y] < data[x])
swap(x, y);
data[x] += data[y];
data[y] = x;
}
return x != y;
}
bool find(int x, int y) { return root(x) == root(y); }
int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
int size(int x) { return -data[root(x)]; }
bool united() {
int comroot = -1;
FOR(i, data.size()) {
if (comroot != -1 && root(i) != comroot)
return false;
comroot = root(i);
}
return true;
}
};
template <class Key, class Compare = less<Key>,
class Allocator = allocator<Key>>
set<Key> operator+(set<Key> &a, set<Key> &b) {
set<Key> c = a;
for (auto i : b)
c.insert(i);
return c;
}
template <class Key, class Compare = less<Key>,
class Allocator = allocator<Key>>
set<Key> operator+=(set<Key> &a, set<Key> &b) {
for (auto &i : b)
a.insert(i);
return a;
}
template <class Key, class Compare = less<Key>,
class Allocator = allocator<Key>>
set<Key> operator*(set<Key> &a, set<Key> &b) {
set<Key> c;
for (auto &i : a)
if (b.count(i))
c.insert(i);
return c;
}
template <class Key, class Compare = less<Key>,
class Allocator = allocator<Key>>
set<Key> operator*=(set<Key> &a, set<Key> &b) {
set<Key> c;
for (auto &i : a)
if (b.count(i))
c.insert(i);
return a = c;
}
template <class Key, class Compare = less<Key>,
class Allocator = allocator<Key>>
set<Key> operator-(set<Key> &a, set<Key> &b) {
set<Key> c;
for (auto &i : a)
if (!b.count(i))
c.insert(i);
return c;
}
template <class Key, class Compare = less<Key>,
class Allocator = allocator<Key>>
set<Key> operator-=(set<Key> &a, set<Key> &b) {
set<Key> c;
for (auto &i : a)
if (!b.count(i))
c.insert(i);
return a = c;
}
static inline int ri() {
int a;
scanf("%d", &a);
return a;
}
int mpow(int num, int times) {
mint next = num;
mint res = 1;
while (num) {
if (num % 2)
res *= next;
next *= next;
num /= 2;
}
return res.x;
}
int int_less(const void *a, const void *b) {
return (*((const int *)a) - *((const int *)b));
}
int int_greater(const void *a, const void *b) {
return (*((const int *)b) - *((const int *)a));
}
void repl(string &s, char a, char b) {
FOR(i, s.size()) {
if (s[i] == a)
s[i] = b;
else if (s[i] == b)
s[i] = a;
}
}
int main() {
string s;
string t;
cin >> s;
cin >> t;
FOR(i, s.size()) {
if (s[i] != t[i]) {
char c1 = s[i];
char c2 = t[i];
// cout << c1 << c2 << endl;
repl(s, c1, c2);
}
}
cout << (s == t ? "Yes" : "No") << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define countof(a) (sizeof(a) / sizeof(*a))
#define vi vector<int>
#define vvi vector<vector<int>>
#define vpi vector<pi>
#define pi pair<int, int>
#define fi first
#define se second
#define all(n) n.begin(), n.end()
#define FOR(var, to) for (register s64 var = 0; var < (s64)to; var++)
#define FROMTO(var, from, to) \
for (register s64 var = from; var <= (s64)to; var++)
#define INIT(var, val) FOR(i, countof(var)) var[i] = val
#define INPUT(var) FOR(i, countof(var)) cin >> var[i]
#define INPUT1(var) FOR(i, countof(var)) cin >> var[i], var[i]--
#define SORT(v) qsort(v, countof(v), sizeof(*v), int_less)
#define SORTT(v) qsort(v, countof(v), sizeof(*v), int_greater)
#define QSORT(v, b) qsort(v, countof(v), sizeof(*v), b)
#define MOD 1000000007
#define INF ((1 << 30) - 1)
#define LINF ((1LL << 62) - 1)
typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;
template <int mod> struct ModInt {
int x;
ModInt() : x(0) {}
ModInt(long long y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
ModInt &operator+=(const ModInt &p) {
if ((x += p.x) >= mod)
x -= mod;
return *this;
}
ModInt &operator-=(const ModInt &p) {
if ((x += mod - p.x) >= mod)
x -= mod;
return *this;
}
ModInt &operator*=(const ModInt &p) {
x = (int)(1LL * x * p.x % mod);
return *this;
}
ModInt &operator/=(const ModInt &p) {
*this *= p.inverse();
return *this;
}
ModInt operator-() const { return ModInt(-x); }
ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
bool operator==(const ModInt &p) const { return x == p.x; }
bool operator!=(const ModInt &p) const { return x != p.x; }
operator int() const { return x; }
ModInt operator=(const int p) {
x = p;
return ModInt(*this);
}
ModInt inverse() const {
int a = x, b = mod, u = 1, v = 0, t;
while (b > 0) {
t = a / b;
a -= t * b;
swap(a, b);
u -= t * v;
swap(u, v);
}
return ModInt(u);
}
friend ostream &operator<<(ostream &os, const ModInt<mod> &p) {
return os << p.x;
}
friend istream &operator>>(istream &is, ModInt<mod> &a) {
long long x;
is >> x;
a = ModInt<mod>(x);
return (is);
}
};
typedef ModInt<MOD> mint;
struct UnionFind {
vi data;
UnionFind(int size) : data(size, -1) {}
bool unite(int x, int y) {
x = root(x);
y = root(y);
if (x != y) {
if (data[y] < data[x])
swap(x, y);
data[x] += data[y];
data[y] = x;
}
return x != y;
}
bool find(int x, int y) { return root(x) == root(y); }
int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
int size(int x) { return -data[root(x)]; }
bool united() {
int comroot = -1;
FOR(i, data.size()) {
if (comroot != -1 && root(i) != comroot)
return false;
comroot = root(i);
}
return true;
}
};
template <class Key, class Compare = less<Key>,
class Allocator = allocator<Key>>
set<Key> operator+(set<Key> &a, set<Key> &b) {
set<Key> c = a;
for (auto i : b)
c.insert(i);
return c;
}
template <class Key, class Compare = less<Key>,
class Allocator = allocator<Key>>
set<Key> operator+=(set<Key> &a, set<Key> &b) {
for (auto &i : b)
a.insert(i);
return a;
}
template <class Key, class Compare = less<Key>,
class Allocator = allocator<Key>>
set<Key> operator*(set<Key> &a, set<Key> &b) {
set<Key> c;
for (auto &i : a)
if (b.count(i))
c.insert(i);
return c;
}
template <class Key, class Compare = less<Key>,
class Allocator = allocator<Key>>
set<Key> operator*=(set<Key> &a, set<Key> &b) {
set<Key> c;
for (auto &i : a)
if (b.count(i))
c.insert(i);
return a = c;
}
template <class Key, class Compare = less<Key>,
class Allocator = allocator<Key>>
set<Key> operator-(set<Key> &a, set<Key> &b) {
set<Key> c;
for (auto &i : a)
if (!b.count(i))
c.insert(i);
return c;
}
template <class Key, class Compare = less<Key>,
class Allocator = allocator<Key>>
set<Key> operator-=(set<Key> &a, set<Key> &b) {
set<Key> c;
for (auto &i : a)
if (!b.count(i))
c.insert(i);
return a = c;
}
static inline int ri() {
int a;
scanf("%d", &a);
return a;
}
int mpow(int num, int times) {
mint next = num;
mint res = 1;
while (num) {
if (num % 2)
res *= next;
next *= next;
num /= 2;
}
return res.x;
}
int int_less(const void *a, const void *b) {
return (*((const int *)a) - *((const int *)b));
}
int int_greater(const void *a, const void *b) {
return (*((const int *)b) - *((const int *)a));
}
void repl(string &s, char a, char b) {
FOR(i, s.size()) {
if (s[i] == a)
s[i] = b;
else if (s[i] == b)
s[i] = a;
}
}
int main() {
string s;
string t;
cin >> s;
cin >> t;
int n = (int)s.size();
int res = true;
int lasts[26];
FOR(i, 26) {
char last = 0;
FOR(j, n) {
if (s[j] == 'a' + i) {
if (!last)
last = t[j];
else if (t[j] != last) {
res = false;
break;
}
}
}
lasts[i] = last;
FOR(j, i) if (lasts[j] && lasts[j] == last) res = false;
if (!res)
break;
}
cout << (res ? "Yes" : "No") << endl;
return 0;
}
| replace | 219 | 228 | 219 | 240 | TLE | |
p03252 | C++ | Runtime Error | #include <cstring>
#include <iostream>
using namespace std;
int main() {
int arr[26][26];
for (int i = 0; i < 26; i++)
for (int j = 0; j < 26; j++)
arr[i][j] = 0;
char s[20001], t[20001];
cin >> s >> t;
int length = strlen(s);
for (int i = 0; i < length; i++) {
int x = s[i] - 'a', y = t[i] - 'a';
if (arr[x][y] == 0) {
for (int j = 0; j < 26; j++) {
if (arr[x][j] != 1 && j != y)
arr[x][j] = -1;
else if (arr[x][j] == 1) {
printf("No\n");
return 0;
}
if (arr[j][y] != 1 && j != x)
arr[j][y] = -1;
else if (arr[j][y] == 1) {
printf("No\n");
return 0;
}
}
arr[x][y] = 1;
} else if (arr[x][y] == -1) {
printf("No\n");
return 0;
}
}
printf("Yes\n");
return 0;
} | #include <cstring>
#include <iostream>
using namespace std;
int main() {
int arr[26][26];
for (int i = 0; i < 26; i++)
for (int j = 0; j < 26; j++)
arr[i][j] = 0;
char s[200001], t[200001];
cin >> s >> t;
int length = strlen(s);
for (int i = 0; i < length; i++) {
int x = s[i] - 'a', y = t[i] - 'a';
if (arr[x][y] == 0) {
for (int j = 0; j < 26; j++) {
if (arr[x][j] != 1 && j != y)
arr[x][j] = -1;
else if (arr[x][j] == 1) {
printf("No\n");
return 0;
}
if (arr[j][y] != 1 && j != x)
arr[j][y] = -1;
else if (arr[j][y] == 1) {
printf("No\n");
return 0;
}
}
arr[x][y] = 1;
} else if (arr[x][y] == -1) {
printf("No\n");
return 0;
}
}
printf("Yes\n");
return 0;
} | replace | 9 | 10 | 9 | 10 | 0 | |
p03252 | C++ | Runtime Error | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
const int MAXN = 100000;
char a[MAXN + 5], b[MAXN + 5];
int cnt1[30], cnt2[30], num1[MAXN + 5], num2[MAXN + 5];
int alen, blen, Max;
int main() {
scanf("%s%s", a, b);
alen = strlen(a);
blen = strlen(b);
for (int i = 0; i < alen; i++) {
cnt1[a[i] - 'a']++;
if (cnt1[a[i] - 'a'] > Max)
Max = cnt1[a[i] - 'a'];
}
for (int i = 0; i < blen; i++) {
cnt2[b[i] - 'a']++;
if (cnt2[b[i] - 'a'] > Max)
Max = cnt2[b[i] - 'a'];
}
for (int i = 0; i <= 25; i++)
num1[cnt1[i]]++;
for (int i = 0; i <= 25; i++)
num2[cnt2[i]]++;
for (int i = 0; i <= Max; i++)
if (num1[i] != num2[i]) {
printf("No\n");
return 0;
}
printf("Yes\n");
return 0;
}
| #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
const int MAXN = 200000;
char a[MAXN + 5], b[MAXN + 5];
int cnt1[30], cnt2[30], num1[MAXN + 5], num2[MAXN + 5];
int alen, blen, Max;
int main() {
scanf("%s%s", a, b);
alen = strlen(a);
blen = strlen(b);
for (int i = 0; i < alen; i++) {
cnt1[a[i] - 'a']++;
if (cnt1[a[i] - 'a'] > Max)
Max = cnt1[a[i] - 'a'];
}
for (int i = 0; i < blen; i++) {
cnt2[b[i] - 'a']++;
if (cnt2[b[i] - 'a'] > Max)
Max = cnt2[b[i] - 'a'];
}
for (int i = 0; i <= 25; i++)
num1[cnt1[i]]++;
for (int i = 0; i <= 25; i++)
num2[cnt2[i]]++;
for (int i = 0; i <= Max; i++)
if (num1[i] != num2[i]) {
printf("No\n");
return 0;
}
printf("Yes\n");
return 0;
}
| replace | 6 | 7 | 6 | 7 | 0 | |
p03252 | C++ | Time Limit Exceeded | #include <iostream>
#include <string.h>
#include <vector>
using namespace std;
int main() {
string s, t;
cin >> s >> t;
int alphabet[26];
for (int i = 0; i < 26; i++) {
alphabet[i] = -1;
}
vector<vector<int>> all(26, vector<int>());
for (int i = 0; i < s.size(); i++) {
all[s[i] - 97].push_back(i);
}
for (int i = 0; i < s.size(); i++) {
// まずは、s[i]が変わっていないか調べる
if (s[i] == t[i] || alphabet[s[i] - 97] == 1) {
// なにもしない
if (s[i] != t[i]) {
cout << "No" << endl;
break;
}
alphabet[t[i] - 97] = 1;
} else {
// s[i]に該当するところを変えていく
vector<int> ss;
for (int j = 0; j < all[s[i] - 97].size(); j++) {
int sub = all[s[i] - 97][j];
if (sub != i) {
s[sub] = t[i];
}
}
for (int j = 0; j < all[t[i] - 97].size(); j++) {
int sub = all[t[i] - 97][j];
if (sub != i) {
s[sub] = s[i];
}
}
all[s[i] - 97].swap(all[t[i] - 97]);
s[i] = t[i];
alphabet[t[i] - 97] = 1;
}
if (s == t) {
cout << "Yes" << endl;
break;
}
if (i == (s.size() - 1)) {
if (s == t) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
}
}
}
| #include <iostream>
#include <string.h>
#include <vector>
using namespace std;
int main() {
string s, t;
cin >> s >> t;
int alphabet[26];
for (int i = 0; i < 26; i++) {
alphabet[i] = -1;
}
vector<vector<int>> all(26, vector<int>());
for (int i = 0; i < s.size(); i++) {
all[s[i] - 97].push_back(i);
}
for (int i = 0; i < s.size(); i++) {
// まずは、s[i]が変わっていないか調べる
if (s[i] == t[i] || alphabet[s[i] - 97] == 1) {
// なにもしない
if (s[i] != t[i]) {
cout << "No" << endl;
break;
}
alphabet[t[i] - 97] = 1;
} else {
// s[i]に該当するところを変えていく
vector<int> ss;
for (int j = 0; j < all[s[i] - 97].size(); j++) {
int sub = all[s[i] - 97][j];
if (sub != i) {
s[sub] = t[i];
}
if (sub < i) {
cout << "No" << endl;
return 0;
}
}
for (int j = 0; j < all[t[i] - 97].size(); j++) {
int sub = all[t[i] - 97][j];
if (sub != i) {
s[sub] = s[i];
}
}
all[s[i] - 97].swap(all[t[i] - 97]);
s[i] = t[i];
alphabet[t[i] - 97] = 1;
}
if (s == t) {
cout << "Yes" << endl;
break;
}
if (i == (s.size() - 1)) {
if (s == t) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
}
}
} | insert | 34 | 34 | 34 | 38 | TLE | |
p03252 | C++ | Time Limit Exceeded | #include <iostream>
using namespace std;
int main(void) {
string s, t;
cin >> s >> t;
int n = s.size();
bool a[n];
char c1[26] = {}, c2[26] = {};
bool ans = true;
for (int i = 0; i < n; i++) {
c1[s.at(i) - 'a']++;
}
for (int i = 0; i < n; i++) {
c2[t.at(i) - 'a']++;
}
int n1 = 0, n2 = 0;
for (int i = 0; i < 26; i++) {
if (c1[i] > 0)
n1++;
if (c2[i] > 0)
n2++;
}
if (n1 != n2)
ans = false;
for (int i = 0; i < n; i++)
a[i] = true;
for (int i = 0; i < n; i++) {
if (s.at(i) != t.at(i) && a[i]) {
for (int j = i; j < n; j++) {
if (a[i]) {
if (s.at(j) == s.at(i) && t.at(j) != t.at(i)) {
ans = false;
} else if (s.at(j) == s.at(i)) {
a[j] = false;
}
}
}
}
}
if (ans)
cout << "Yes";
else
cout << "No";
} | #include <iostream>
using namespace std;
int main(void) {
string s, t;
cin >> s >> t;
int n = s.size();
bool a[n];
char c1[26] = {}, c2[26] = {};
bool ans = true;
for (int i = 0; i < n; i++) {
c1[s.at(i) - 'a']++;
}
for (int i = 0; i < n; i++) {
c2[t.at(i) - 'a']++;
}
int n1 = 0, n2 = 0;
for (int i = 0; i < 26; i++) {
if (c1[i] > 0)
n1++;
if (c2[i] > 0)
n2++;
}
if (n1 != n2)
ans = false;
for (int i = 0; i < n; i++)
a[i] = true;
for (int i = 0; i < n; i++) {
if (s.at(i) != t.at(i) && a[i]) {
for (int j = i; j < n; j++) {
if (s.at(j) == s.at(i) && t.at(j) != t.at(i)) {
ans = false;
a[j] = false;
} else if (s.at(j) == s.at(i)) {
a[j] = false;
}
}
}
}
if (ans)
cout << "Yes";
else
cout << "No";
}
| replace | 29 | 35 | 29 | 34 | TLE | |
p03252 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define nl cout << "\n"
#define dbg(x) cout << x << " ";
#define fi(a, b) for (int i = a; i < b; i++)
#define fj(a, b) for (int j = a; j < b; j++)
#define UM unordered_map<char, int>
#define ULL unordered_map<ll, int>
void fun() {
string s, t;
cin >> s >> t;
UM ms, mt;
int S = 1, T = 1;
fi(0, s.size()) {
if (ms[s[i]] != mt[t[i]]) {
cout << "No\n";
return;
}
if (ms[s[i]] == 0) {
ms[s[i]] = S;
S++;
}
if (mt[t[i]] == 0) {
mt[t[i]] = T;
T++;
}
}
cout << "Yes\n";
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
#ifndef ONLINE_JUDGE
freopen("/ATOM/input.txt", "r", stdin);
freopen("/ATOM/output.txt", "w", stdout);
#endif
fun();
} | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define nl cout << "\n"
#define dbg(x) cout << x << " ";
#define fi(a, b) for (int i = a; i < b; i++)
#define fj(a, b) for (int j = a; j < b; j++)
#define UM unordered_map<char, int>
#define ULL unordered_map<ll, int>
void fun() {
string s, t;
cin >> s >> t;
UM ms, mt;
int S = 1, T = 1;
fi(0, s.size()) {
if (ms[s[i]] != mt[t[i]]) {
cout << "No\n";
return;
}
if (ms[s[i]] == 0) {
ms[s[i]] = S;
S++;
}
if (mt[t[i]] == 0) {
mt[t[i]] = T;
T++;
}
}
cout << "Yes\n";
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
fun();
} | delete | 35 | 39 | 35 | 35 | 0 | |
p03252 | C++ | Runtime Error | #include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
char s[100005], t[100005];
int main() {
cin >> s >> t;
int fs[26], ft[26];
memset(fs, -1, sizeof(fs));
memset(ft, -1, sizeof(ft));
int l = strlen(s);
int flag = 0;
for (int i = 0; i < l; i++) {
if (fs[s[i] - 'a'] == -1) {
fs[s[i] - 'a'] = t[i];
} else {
if (fs[s[i] - 'a'] != t[i]) {
flag = 1;
break;
}
}
if (ft[t[i] - 'a'] == -1) {
ft[t[i] - 'a'] = s[i];
} else {
if (ft[t[i] - 'a'] != s[i]) {
flag = 1;
break;
}
}
}
if (flag)
cout << "No" << endl;
else
cout << "Yes" << endl;
}
| #include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
char s[200005], t[200005];
int main() {
cin >> s >> t;
int fs[26], ft[26];
memset(fs, -1, sizeof(fs));
memset(ft, -1, sizeof(ft));
int l = strlen(s);
int flag = 0;
for (int i = 0; i < l; i++) {
if (fs[s[i] - 'a'] == -1) {
fs[s[i] - 'a'] = t[i];
} else {
if (fs[s[i] - 'a'] != t[i]) {
flag = 1;
break;
}
}
if (ft[t[i] - 'a'] == -1) {
ft[t[i] - 'a'] = s[i];
} else {
if (ft[t[i] - 'a'] != s[i]) {
flag = 1;
break;
}
}
}
if (flag)
cout << "No" << endl;
else
cout << "Yes" << endl;
}
| replace | 4 | 5 | 4 | 5 | 0 | |
p03252 | Python | Runtime Error | def solve(string):
s, t = map(int, string.split())
c_s = sorted([s.count(_c) for _c in set(s)])
c_t = sorted([t.count(_c) for _c in set(t)])
if c_s == c_t:
return "Yes"
else:
return "No"
if __name__ == "__main__":
print(solve("\n".join([input(), input()])))
| def solve(string):
s, t = string.split()
c_s = sorted([s.count(_c) for _c in set(s)])
c_t = sorted([t.count(_c) for _c in set(t)])
if c_s == c_t:
return "Yes"
else:
return "No"
if __name__ == "__main__":
print(solve("\n".join([input(), input()])))
| replace | 1 | 2 | 1 | 2 | ValueError: invalid literal for int() with base 10: 'azzel' | Traceback (most recent call last):
File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03252/Python/s340167344.py", line 14, in <module>
print(solve('\n'.join([input(), input()])))
File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03252/Python/s340167344.py", line 2, in solve
s, t = map(int, string.split())
ValueError: invalid literal for int() with base 10: 'azzel'
|
p03252 | Python | Time Limit Exceeded | S = input()
T = input()
n = len(S)
for i in range(n):
s = S[i]
t = T[i]
S = S.translate(str.maketrans({s: t, t: s}))
if S == T:
print("Yes")
else:
print("No")
| S = input()
T = input()
st = {}
ts = {}
for s, t in zip(S, T):
if s in st and st[s] != t:
print("No")
exit()
if t in ts and ts[t] != s:
print("No")
exit()
st[s] = t
ts[t] = s
print("Yes")
| replace | 2 | 11 | 2 | 14 | TLE | |
p03252 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
int main() {
string s, t;
cin >> s >> t;
for (int i = 0; i < s.size(); i++) {
if (s[i] != t[i]) {
char c = s[i];
for (int j = 0; j < s.size(); j++) {
if (s[j] == c) {
s[j] = t[i];
} else if (s[j] == t[i]) {
s[j] = c;
}
}
}
}
cout << (s == t ? "Yes" : "No");
} | #include <bits/stdc++.h>
using namespace std;
int main() {
string s, t;
cin >> s >> t;
for (int i = 0; i < s.size(); i++) {
if (s[i] != t[i]) {
char c = s[i];
for (int j = 0; j < s.size(); j++) {
if (j < i) {
if (t[i] == s[j]) {
cout << "No";
return 0;
}
}
if (s[j] == c) {
s[j] = t[i];
} else if (s[j] == t[i]) {
s[j] = c;
}
}
}
}
cout << (s == t ? "Yes" : "No");
} | insert | 9 | 9 | 9 | 15 | TLE | |
p03252 | C++ | Runtime Error | /*
URL_HERE
*/
/*
*/
#ifdef _WIN32
#pragma warning(disable : 4996)
#endif
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unordered_map>
using namespace std;
FILE *_fin = stdin;
FILE *_fout = stdout;
#define PI 3.141592653589793238462643383279502884197169399375105820974
#define ten5p1 100001
#define ten6p1 1000001
#define ten8p1 100000001
#define ten9p1 1000000001
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define rep(var, n) for (int var = 0; var < n; ++var)
#define repi(n) rep(i, n)
#define repj(n) rep(j, n)
#define repi1(n) for (int i = 1; i < n; ++i)
#define repj1(n) for (int j = 1; j < n; ++j)
int _min(int a, int b) { return a <= b ? a : b; }
int _min(ll a, ll b) { return a <= b ? a : b; }
int _max(int a, int b) { return a >= b ? a : b; }
int _max(ll a, ll b) { return a >= b ? a : b; }
void zero(int *data, int n) { memset(data, 0, sizeof(int) * n); }
void zero(ll *data, int n) { memset(data, 0, sizeof(ll) * n); }
void zero(char *data, int n) { memset(data, 0, sizeof(char) * n); }
char readc() {
char var;
fscanf(_fin, "%c", &var);
return var;
}
int readi() {
int var;
fscanf(_fin, "%d", &var);
return var;
}
ll readll() {
ll var;
fscanf(_fin, "%lld", &var);
return var;
}
void repread(int *data, int n) { repi(n) data[i] = readi(); }
void repread(ll *data, int n) { repi(n) data[i] = readll(); }
int reads(char *str, int maxsize) {
for (;;) {
if (fgets(str, maxsize, _fin) == NULL)
break;
if (str[0] != '\n' && str[0] != '\r')
break;
}
int slen = strlen(str);
if (slen == 0)
return 0;
if (str[slen - 1] == '\n' || str[slen - 1] == '\r')
str[--slen] = 0;
return slen;
}
#define writec(var) fprintf(_fout, "%c", var)
#define writecsp(var) fprintf(_fout, "%c ", var)
#define writecln(var) fprintf(_fout, "%c\n", var)
#define writei(var) fprintf(_fout, "%d", var)
#define writeisp(var) fprintf(_fout, "%d ", var)
#define writellsp(var) fprintf(_fout, "%lld ", var)
#define writeiln(var) fprintf(_fout, "%d\n", var)
#define writellln(var) fprintf(_fout, "%lld\n", var)
#define writeulln(var) fprintf(_fout, "%llu\n", var)
#define writefln(var) fprintf(_fout, "%f\n", var)
#define writes(str) fprintf(_fout, "%s", str)
#define writesp() fprintf(_fout, " ")
#define writeln() fprintf(_fout, "\n")
#define RUN_LOCAL(testfilename) \
{ \
_fin = fopen(testfilename, "r"); \
if (_fin == NULL) \
_fin = stdin; \
}
#define swap(type, a, b) \
{ \
type t = a; \
a = b; \
b = t; \
}
#define sort(data, n) std::sort(data, data + n)
// #define mod(a,b) b==0 ? 0 : a==0 ? 0 :(a>0 ? a%b : b + a % b) //what the hell
// is this...
ll gcd(ll a, ll b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
ll g = gcd(a, b);
return (a / g) * b;
}
void reverse(char *data, int n) {
int k = n >> 1;
repi(k) {
char tmp = data[i];
data[i] = data[n - i - 1];
data[n - i - 1] = tmp;
}
}
void reverse(int *data, int n) {
int k = n >> 1;
repi(k) {
int tmp = data[i];
data[i] = data[n - i - 1];
data[n - i - 1] = tmp;
}
}
#define _Vec(type, name) \
struct name { \
type *data; \
int size; \
int n; \
}; \
void init(name *t, int size) { \
t->data = (type *)malloc(sizeof(type) * size); \
t->size = size; \
t->n = 0; \
} \
void resize(name *t) { \
int ns = t->size * 1.2f; \
t->data = (type *)realloc(t->data, sizeof(type) * ns); \
t->size = ns; \
} \
void add(name *t, type val) { \
if (t->n >= t->size) \
resize(t); \
int k = t->n; \
t->data[k] = val; \
t->n = k + 1; \
} \
void free(name *t) { free(t->data); }
_Vec(int, Veci) _Vec(long long, Vecll) _Vec(char *, Vecs)
#define _ispal(type, name) \
int name(type *a, type *b, int n) { \
repi(n) { \
if (a[i] != b[n - i - 1]) { \
return 0; \
} \
} \
return 1; \
}
_ispal(int, ispali) _ispal(char, ispalc)
#define _Pair(type, name) \
struct name { \
type x, y; \
}; \
int cmp_##name(const void *_a, const void *_b) { \
name *a = (name *)_a; \
name *b = (name *)_b; \
if (a->x == b->x) { \
if (a->y < b->y) \
return -1; \
else \
return 1; \
} \
if (a->x < b->x) \
return -1; \
else \
return 1; \
} \
void sort_##name(name *d, int n) { qsort(d, n, sizeof(name), cmp_##name); }
_Pair(int, Pairi)
int cmp_Str(const void *_a, const void *_b) {
char *a = *((char **)_a);
char *b = *((char **)_b);
return strcmp(a, b);
}
void sort_Str(char **str, int n) { qsort(str, n, sizeof(char *), cmp_Str); }
ll expmod(ll x, ll n, ll m) {
ll ans = 1;
for (; n;) {
if (n & 1)
ans = (ans * x) % m;
x = (x * x) % m;
n >>= 1;
}
return ans;
}
ll combmod(ll n, ll k, ll m) {
ll ret = 1;
ll div = 1;
for (ll i = 0; i < k; ++i) {
ret = (ret * (n - i) % m) % m;
div = (div * (i + 1)) % m;
}
div = expmod(div, m - 2, m) % m;
return (ret * div) % m;
}
//------------------------------------------
//------------
int main() {
RUN_LOCAL("xxtestcase_05in.txt");
static char s[2 * ten5p1];
static char t[2 * ten5p1];
int len = reads(s, 2 * ten5p1);
reads(t, 2 * ten5p1);
static int sn[26] = {0};
static int tn[26] = {0};
repi(len) {
sn[s[i] - 'a']++;
tn[t[i] - 'a']++;
}
static int sl[26] = {0};
int sln = 0;
static int tl[26] = {0};
int tln = 0;
repi(len) {
if (sn[i] != 0)
sl[sln++] = sn[i];
if (tn[i] != 0)
tl[tln++] = tn[i];
}
if (sln != tln) {
writes("No\n");
return 0;
}
repi(sln) {
if (sl[i] != tl[i]) {
writes("No\n");
return 0;
}
}
writes("Yes\n");
return 0;
}
| /*
URL_HERE
*/
/*
*/
#ifdef _WIN32
#pragma warning(disable : 4996)
#endif
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unordered_map>
using namespace std;
FILE *_fin = stdin;
FILE *_fout = stdout;
#define PI 3.141592653589793238462643383279502884197169399375105820974
#define ten5p1 100001
#define ten6p1 1000001
#define ten8p1 100000001
#define ten9p1 1000000001
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define rep(var, n) for (int var = 0; var < n; ++var)
#define repi(n) rep(i, n)
#define repj(n) rep(j, n)
#define repi1(n) for (int i = 1; i < n; ++i)
#define repj1(n) for (int j = 1; j < n; ++j)
int _min(int a, int b) { return a <= b ? a : b; }
int _min(ll a, ll b) { return a <= b ? a : b; }
int _max(int a, int b) { return a >= b ? a : b; }
int _max(ll a, ll b) { return a >= b ? a : b; }
void zero(int *data, int n) { memset(data, 0, sizeof(int) * n); }
void zero(ll *data, int n) { memset(data, 0, sizeof(ll) * n); }
void zero(char *data, int n) { memset(data, 0, sizeof(char) * n); }
char readc() {
char var;
fscanf(_fin, "%c", &var);
return var;
}
int readi() {
int var;
fscanf(_fin, "%d", &var);
return var;
}
ll readll() {
ll var;
fscanf(_fin, "%lld", &var);
return var;
}
void repread(int *data, int n) { repi(n) data[i] = readi(); }
void repread(ll *data, int n) { repi(n) data[i] = readll(); }
int reads(char *str, int maxsize) {
for (;;) {
if (fgets(str, maxsize, _fin) == NULL)
break;
if (str[0] != '\n' && str[0] != '\r')
break;
}
int slen = strlen(str);
if (slen == 0)
return 0;
if (str[slen - 1] == '\n' || str[slen - 1] == '\r')
str[--slen] = 0;
return slen;
}
#define writec(var) fprintf(_fout, "%c", var)
#define writecsp(var) fprintf(_fout, "%c ", var)
#define writecln(var) fprintf(_fout, "%c\n", var)
#define writei(var) fprintf(_fout, "%d", var)
#define writeisp(var) fprintf(_fout, "%d ", var)
#define writellsp(var) fprintf(_fout, "%lld ", var)
#define writeiln(var) fprintf(_fout, "%d\n", var)
#define writellln(var) fprintf(_fout, "%lld\n", var)
#define writeulln(var) fprintf(_fout, "%llu\n", var)
#define writefln(var) fprintf(_fout, "%f\n", var)
#define writes(str) fprintf(_fout, "%s", str)
#define writesp() fprintf(_fout, " ")
#define writeln() fprintf(_fout, "\n")
#define RUN_LOCAL(testfilename) \
{ \
_fin = fopen(testfilename, "r"); \
if (_fin == NULL) \
_fin = stdin; \
}
#define swap(type, a, b) \
{ \
type t = a; \
a = b; \
b = t; \
}
#define sort(data, n) std::sort(data, data + n)
// #define mod(a,b) b==0 ? 0 : a==0 ? 0 :(a>0 ? a%b : b + a % b) //what the hell
// is this...
ll gcd(ll a, ll b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
ll g = gcd(a, b);
return (a / g) * b;
}
void reverse(char *data, int n) {
int k = n >> 1;
repi(k) {
char tmp = data[i];
data[i] = data[n - i - 1];
data[n - i - 1] = tmp;
}
}
void reverse(int *data, int n) {
int k = n >> 1;
repi(k) {
int tmp = data[i];
data[i] = data[n - i - 1];
data[n - i - 1] = tmp;
}
}
#define _Vec(type, name) \
struct name { \
type *data; \
int size; \
int n; \
}; \
void init(name *t, int size) { \
t->data = (type *)malloc(sizeof(type) * size); \
t->size = size; \
t->n = 0; \
} \
void resize(name *t) { \
int ns = t->size * 1.2f; \
t->data = (type *)realloc(t->data, sizeof(type) * ns); \
t->size = ns; \
} \
void add(name *t, type val) { \
if (t->n >= t->size) \
resize(t); \
int k = t->n; \
t->data[k] = val; \
t->n = k + 1; \
} \
void free(name *t) { free(t->data); }
_Vec(int, Veci) _Vec(long long, Vecll) _Vec(char *, Vecs)
#define _ispal(type, name) \
int name(type *a, type *b, int n) { \
repi(n) { \
if (a[i] != b[n - i - 1]) { \
return 0; \
} \
} \
return 1; \
}
_ispal(int, ispali) _ispal(char, ispalc)
#define _Pair(type, name) \
struct name { \
type x, y; \
}; \
int cmp_##name(const void *_a, const void *_b) { \
name *a = (name *)_a; \
name *b = (name *)_b; \
if (a->x == b->x) { \
if (a->y < b->y) \
return -1; \
else \
return 1; \
} \
if (a->x < b->x) \
return -1; \
else \
return 1; \
} \
void sort_##name(name *d, int n) { qsort(d, n, sizeof(name), cmp_##name); }
_Pair(int, Pairi)
int cmp_Str(const void *_a, const void *_b) {
char *a = *((char **)_a);
char *b = *((char **)_b);
return strcmp(a, b);
}
void sort_Str(char **str, int n) { qsort(str, n, sizeof(char *), cmp_Str); }
ll expmod(ll x, ll n, ll m) {
ll ans = 1;
for (; n;) {
if (n & 1)
ans = (ans * x) % m;
x = (x * x) % m;
n >>= 1;
}
return ans;
}
ll combmod(ll n, ll k, ll m) {
ll ret = 1;
ll div = 1;
for (ll i = 0; i < k; ++i) {
ret = (ret * (n - i) % m) % m;
div = (div * (i + 1)) % m;
}
div = expmod(div, m - 2, m) % m;
return (ret * div) % m;
}
//------------------------------------------
//------------
int main() {
RUN_LOCAL("xxtestcase_05in.txt");
static char s[2 * ten5p1];
static char t[2 * ten5p1];
int len = reads(s, 2 * ten5p1);
reads(t, 2 * ten5p1);
static int sn[26] = {0};
static int tn[26] = {0};
repi(len) {
sn[s[i] - 'a']++;
tn[t[i] - 'a']++;
}
sort(sn, 26);
sort(tn, 26);
repi(26) {
if (sn[i] != tn[i]) {
writes("No\n");
return 0;
}
}
writes("Yes\n");
return 0;
}
| replace | 228 | 246 | 228 | 232 | 0 | |
p03252 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
char ss[111111];
void gen(vector<vector<int>> &s) {
scanf("%s", ss);
for (int i = 0; ss[i]; i++) {
s[ss[i] - 'a'].push_back(i);
}
sort(s.begin(), s.end());
}
int main() {
vector<vector<int>> s1(26), s2(26);
gen(s1);
gen(s2);
puts(s1 == s2 ? "Yes" : "No");
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
char ss[222222];
void gen(vector<vector<int>> &s) {
scanf("%s", ss);
for (int i = 0; ss[i]; i++) {
s[ss[i] - 'a'].push_back(i);
}
sort(s.begin(), s.end());
}
int main() {
vector<vector<int>> s1(26), s2(26);
gen(s1);
gen(s2);
puts(s1 == s2 ? "Yes" : "No");
return 0;
}
| replace | 2 | 3 | 2 | 3 | 0 | |
p03252 | C++ | Runtime Error | #include <bits/stdc++.h>
#define f(i, n) for (int i = 0; i < (n); i++)
#define ll long long
using namespace std;
int nums[100004], numt[100004];
string s, t;
int mojis[40], mojit[40];
int main() {
cin >> s >> t;
int c = 1;
for (int i = 0; i < s.size(); i++) {
if (!mojis[s[i] - 'a']) {
mojis[s[i] - 'a'] = c;
c++;
}
nums[i] = mojis[s[i] - 'a'];
}
c = 1;
for (int i = 0; i < s.size(); i++) {
if (!mojit[t[i] - 'a']) {
mojit[t[i] - 'a'] = c;
c++;
}
numt[i] = mojit[t[i] - 'a'];
}
for (int i = 0; i < s.size(); i++) {
if (nums[i] != numt[i]) {
cout << "No" << endl;
return 0;
}
}
cout << "Yes" << endl;
}
| #include <bits/stdc++.h>
#define f(i, n) for (int i = 0; i < (n); i++)
#define ll long long
using namespace std;
int nums[200004], numt[200004];
string s, t;
int mojis[40], mojit[40];
int main() {
cin >> s >> t;
int c = 1;
for (int i = 0; i < s.size(); i++) {
if (!mojis[s[i] - 'a']) {
mojis[s[i] - 'a'] = c;
c++;
}
nums[i] = mojis[s[i] - 'a'];
}
c = 1;
for (int i = 0; i < s.size(); i++) {
if (!mojit[t[i] - 'a']) {
mojit[t[i] - 'a'] = c;
c++;
}
numt[i] = mojit[t[i] - 'a'];
}
for (int i = 0; i < s.size(); i++) {
if (nums[i] != numt[i]) {
cout << "No" << endl;
return 0;
}
}
cout << "Yes" << endl;
}
| replace | 4 | 5 | 4 | 5 | 0 | |
p03252 | C++ | Runtime Error | #include <algorithm>
#include <bits/stdc++.h>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;
using namespace std;
void solve() {}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
string s, t;
cin >> s >> t;
vector<vector<int>> v(26, vector<int>(100001));
vector<vector<int>> g(26, vector<int>(100001));
for (int i = 0; i < 26; i++) {
v[i][0] = 0;
g[i][0] = 0;
}
// cout << "Hello" << endl;
rep(i, t.size()) {
int m = t[i] - 'a';
v[m][0]++;
v[m][v[m][0]] = i;
}
rep(i, s.size()) {
int m = s[i] - 'a';
g[m][0]++;
g[m][g[m][0]] = i;
}
rep(i, 26) {
// cout << i << endl;
if (v[i][0] > 1) {
bool flag = false;
char c;
rep(j, v[i][0]) {
if (!flag) {
c = s[v[i][j + 1]];
flag = true;
} else {
if (c != s[v[i][j + 1]]) {
cout << "No" << endl;
return 0;
}
}
}
}
if (g[i][0] > 1) {
bool flag = false;
char c;
rep(j, g[i][0]) {
if (!flag) {
c = t[g[i][j + 1]];
flag = true;
} else {
if (c != t[g[i][j + 1]]) {
cout << "No" << endl;
return 0;
}
}
}
}
// else if(v[i][0]==1){
// char c = s[v[i][1]];
// rep(j,g[i][0]){
// if(c!=t[g[i][j+1]]){
// cout << "No" << endl;
// return 0;
// }
// }
// }
}
cout << "Yes" << endl;
return 0;
} | #include <algorithm>
#include <bits/stdc++.h>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;
using namespace std;
void solve() {}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
string s, t;
cin >> s >> t;
vector<vector<int>> v(26, vector<int>(200002));
vector<vector<int>> g(26, vector<int>(200002));
for (int i = 0; i < 26; i++) {
v[i][0] = 0;
g[i][0] = 0;
}
// cout << "Hello" << endl;
rep(i, t.size()) {
int m = t[i] - 'a';
v[m][0]++;
v[m][v[m][0]] = i;
}
rep(i, s.size()) {
int m = s[i] - 'a';
g[m][0]++;
g[m][g[m][0]] = i;
}
rep(i, 26) {
// cout << i << endl;
if (v[i][0] > 1) {
bool flag = false;
char c;
rep(j, v[i][0]) {
if (!flag) {
c = s[v[i][j + 1]];
flag = true;
} else {
if (c != s[v[i][j + 1]]) {
cout << "No" << endl;
return 0;
}
}
}
}
if (g[i][0] > 1) {
bool flag = false;
char c;
rep(j, g[i][0]) {
if (!flag) {
c = t[g[i][j + 1]];
flag = true;
} else {
if (c != t[g[i][j + 1]]) {
cout << "No" << endl;
return 0;
}
}
}
}
// else if(v[i][0]==1){
// char c = s[v[i][1]];
// rep(j,g[i][0]){
// if(c!=t[g[i][j+1]]){
// cout << "No" << endl;
// return 0;
// }
// }
// }
}
cout << "Yes" << endl;
return 0;
} | replace | 23 | 25 | 23 | 25 | 0 | |
p03252 | C++ | Time Limit Exceeded | #include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void) {
int L[30][30] = {0};
char *S1 = (char *)calloc(3 * 100000, sizeof(char));
char *S2 = (char *)calloc(3 * 100000, sizeof(char));
scanf("%s %s", S1, S2);
for (int i = 0; i < strlen(S1); i++) {
L[S1[i] - 'a'][S2[i] - 'a'] = 1;
// L[S2[i]-'a'][S1[i]-'a']=1;
}
for (int i = 0; i < 30; i++) {
int cnt = 0;
for (int j = 0; j < 30; j++) {
if (L[i][j] == 1) {
cnt++;
}
if (cnt > 1) {
printf("No\n");
return 0;
}
}
}
for (int i = 0; i < 30; i++) {
int cnt = 0;
for (int j = 0; j < 30; j++) {
if (L[j][i] == 1) {
cnt++;
}
if (cnt > 1) {
printf("No\n");
return 0;
}
}
}
printf("Yes\n");
return 0;
}
| #include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void) {
int L[30][30] = {0};
char *S1 = (char *)calloc(3 * 100000, sizeof(char));
char *S2 = (char *)calloc(3 * 100000, sizeof(char));
scanf("%s %s", S1, S2);
int n = strlen(S1);
for (int i = 0; i < n; i++) {
L[S1[i] - 'a'][S2[i] - 'a'] = 1;
// L[S2[i]-'a'][S1[i]-'a']=1;
}
for (int i = 0; i < 30; i++) {
int cnt = 0;
for (int j = 0; j < 30; j++) {
if (L[i][j] == 1) {
cnt++;
}
if (cnt > 1) {
printf("No\n");
return 0;
}
}
}
for (int i = 0; i < 30; i++) {
int cnt = 0;
for (int j = 0; j < 30; j++) {
if (L[j][i] == 1) {
cnt++;
}
if (cnt > 1) {
printf("No\n");
return 0;
}
}
}
printf("Yes\n");
return 0;
}
| replace | 10 | 11 | 10 | 12 | TLE | |
p03252 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define Rep(i, n) For(i, 0, (n))
#define Rrep(i, n) for (int i = (n - 1); i >= 0; i--)
#define Itr(i, c) for (typeof(c.begin()) i = c.begin(); i != c.end(); i++)
#define pb push_back
const int inf = 999999999;
const int mod = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int c1[26], c2[26];
int main() {
string s, t;
cin >> s >> t;
int l = s.size();
Rep(i, l) {
int k = s[i] - 'a';
c1[k] += 1;
k = t[i] - 'a';
c2[k] += 1;
}
sort(c1, c1 + 26);
sort(c2, c2 + 26);
bool flag = true;
Rep(i, l) {
if (c1[i] == c2[i]) {
continue;
} else {
flag = false;
}
}
if (flag) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define Rep(i, n) For(i, 0, (n))
#define Rrep(i, n) for (int i = (n - 1); i >= 0; i--)
#define Itr(i, c) for (typeof(c.begin()) i = c.begin(); i != c.end(); i++)
#define pb push_back
const int inf = 999999999;
const int mod = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int c1[26], c2[26];
int main() {
string s, t;
cin >> s >> t;
int l = s.size();
Rep(i, l) {
int k = s[i] - 'a';
c1[k] += 1;
k = t[i] - 'a';
c2[k] += 1;
}
sort(c1, c1 + 26);
sort(c2, c2 + 26);
bool flag = true;
Rep(i, 26) {
if (c1[i] == c2[i]) {
continue;
} else {
flag = false;
}
}
if (flag) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
return 0;
}
| replace | 31 | 32 | 31 | 32 | 0 | |
p03252 | C++ | Runtime Error | #include <iostream>
#include <string>
using namespace std;
int main() {
string S, T;
cin >> S >> T;
string begin(26, -1);
string end(26, -1);
bool flag = true;
for (int i = 0; i < S.size(); i++) {
int a = S[i] - 'a';
int b = T[i] - 'a';
if (begin[i] != -1 || end[i] != -1) {
if (begin[a] != b || end[b] != a) {
flag = false;
break;
}
}
begin[a] = b;
end[b] = a;
}
if (flag) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
return 0;
} | #include <iostream>
#include <string>
using namespace std;
int main() {
string S, T;
cin >> S >> T;
string begin(26, -1);
string end(26, -1);
bool flag = true;
for (int i = 0; i < S.size(); i++) {
int a = S[i] - 'a';
int b = T[i] - 'a';
if (begin[a] != -1 || end[b] != -1) {
if (begin[a] != b || end[b] != a) {
flag = false;
break;
}
}
begin[a] = b;
end[b] = a;
}
if (flag) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
return 0;
}
| replace | 17 | 18 | 17 | 18 | 0 | |
p03252 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll, ll>;
#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define REP(i, m, n) for (ll(i) = (m), (i_len) = (n); (i) < (i_len); ++(i))
#define FORR(i, v) for (auto(i) : v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) \
ASC((x)); \
REV((x))
#define pb push_back
#define eb emplace_back
int main() {
string S, T;
cin >> S >> T;
vector<set<char>> A(26), B(26);
REP(i, 0, SZ(S)) {
A[S[i] - 'a'].insert(T[i]);
B[T[i] - 'a'].insert(S[i]);
}
bool f = true;
REP(i, 0, SZ(S)) {
if (SZ(A[i]) > 1 || SZ(B[i]) > 1)
f = false;
}
if (f)
PR("Yes");
else
PR("No");
return 0;
}
/*
*/ | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll, ll>;
#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define REP(i, m, n) for (ll(i) = (m), (i_len) = (n); (i) < (i_len); ++(i))
#define FORR(i, v) for (auto(i) : v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) \
ASC((x)); \
REV((x))
#define pb push_back
#define eb emplace_back
int main() {
string S, T;
cin >> S >> T;
vector<set<char>> A(26), B(26);
REP(i, 0, SZ(S)) {
A[S[i] - 'a'].insert(T[i]);
B[T[i] - 'a'].insert(S[i]);
}
bool f = true;
REP(i, 0, 26) {
if (SZ(A[i]) > 1 || SZ(B[i]) > 1)
f = false;
}
if (f)
PR("Yes");
else
PR("No");
return 0;
}
/*
*/ | replace | 38 | 39 | 38 | 39 | 0 | |
p03252 | C++ | Runtime Error | #include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
int N, K;
string S, T;
int a[110] = {};
int b[110] = {};
int c[110] = {};
int d[110] = {};
bool last;
int main() {
cin >> S >> T;
int N = S.size();
for (int i = 0; i < N; i++) {
a[S[i] - 'a']++;
b[T[i] - 'a']++;
}
// 入れ終わる
// a[i]は0がaでそこからなんこあるか
for (int i = 0; i < 26; i++) {
c[a[i]]++;
d[b[i]]++;
}
for (int i = 0; i < N; i++) {
if (c[i] != d[i]) {
cout << "No" << endl;
return 0;
}
}
cout << "Yes" << endl;
return 0;
} | #include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
int N, K;
string S, T;
int a[110] = {};
int b[110] = {};
int c[200010] = {};
int d[200010] = {};
bool last;
int main() {
cin >> S >> T;
int N = S.size();
for (int i = 0; i < N; i++) {
a[S[i] - 'a']++;
b[T[i] - 'a']++;
}
// 入れ終わる
// a[i]は0がaでそこからなんこあるか
for (int i = 0; i < 26; i++) {
c[a[i]]++;
d[b[i]]++;
}
for (int i = 0; i < N; i++) {
if (c[i] != d[i]) {
cout << "No" << endl;
return 0;
}
}
cout << "Yes" << endl;
return 0;
} | replace | 27 | 29 | 27 | 29 | 0 | |
p03252 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
int main() {
string S, T;
cin >> S >> T;
int size = S.size();
for (int i = 0; i < size; i++) {
if (S[i] != T[i]) {
char cs = S[i], ct = T[i];
for (int j = 0; j < size; j++) {
if (S[j] == cs)
S[j] = ct;
else if (S[j] == ct)
S[j] = cs;
}
}
}
if (S == T)
cout << "Yes" << endl;
else
cout << "No" << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
string S, T;
cin >> S >> T;
int size = S.size();
vector<int> ss = {1}, tt = {1};
for (int i = 1; i < size; i++) {
if (S.at(i - 1) == S.at(i))
ss.back()++;
else
ss.push_back(1);
if (T.at(i - 1) == T.at(i))
tt.back()++;
else
tt.push_back(1);
}
if (ss != tt) {
cout << "No" << endl;
return 0;
}
for (int i = 0; i < size; i++) {
if (S[i] != T[i]) {
char cs = S[i], ct = T[i];
for (int j = 0; j < size; j++) {
if (S[j] == cs)
S[j] = ct;
else if (S[j] == ct)
S[j] = cs;
}
}
}
if (S == T)
cout << "Yes" << endl;
else
cout << "No" << endl;
} | insert | 7 | 7 | 7 | 23 | TLE | |
p03252 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define per(i, n) for (ll i = n - 1; i >= 0; i--)
#define perl(i, r, l) for (ll i = r - 1; i >= l; i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define all(x) (x).begin(), (x).end()
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
const ll MOD = 1000000007;
const ll MOD9 = 998244353;
const int inf = 1e9 + 10;
const ll INF = 4e18;
const ll dy[8] = {1, 0, -1, 0, 1, 1, -1, -1};
const ll dx[8] = {0, -1, 0, 1, 1, -1, 1, -1};
using Graph = vector<vector<int>>;
const double pi = acos(-1);
double nCk(int n, int k) {
double res = 1.0;
for (int i = 0; i < n; i++) {
res *= 0.5;
}
for (int i = 0; i < k; i++) {
res *= (double)(n - i);
res /= (double)(k - i);
}
return res;
}
int main() {
// cout << fixed << setprecision(12);
string s, t;
cin >> s >> t;
ll ca = 0;
ll cb = 0;
ll n = s.size();
ll a[30] = {};
ll b[30] = {};
char q;
rep(i, n) {
ll k = t.at(i) - 'a';
// cout << k << endl;
a[i] = k;
}
// rep(i,n){
// cout << a[i] << endl;}
rep(i, 30) {
rep(j, n) {
// cout << "i " << i << endl;
if (a[j] == i && ca == 0) {
ca++;
q = s.at(j);
// cout << q << endl;
continue;
}
if ((a[j] == i && s.at(j) != q) || (a[j] != i && s.at(j) == q)) {
cb++;
// cout << i << " " << j << endl;
goto asd;
}
}
ca = 0;
q = '6';
}
asd:
if (cb > 0) {
cout << "No" << endl;
} else {
cout << "Yes" << endl;
}
} | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define per(i, n) for (ll i = n - 1; i >= 0; i--)
#define perl(i, r, l) for (ll i = r - 1; i >= l; i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define all(x) (x).begin(), (x).end()
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
const ll MOD = 1000000007;
const ll MOD9 = 998244353;
const int inf = 1e9 + 10;
const ll INF = 4e18;
const ll dy[8] = {1, 0, -1, 0, 1, 1, -1, -1};
const ll dx[8] = {0, -1, 0, 1, 1, -1, 1, -1};
using Graph = vector<vector<int>>;
const double pi = acos(-1);
double nCk(int n, int k) {
double res = 1.0;
for (int i = 0; i < n; i++) {
res *= 0.5;
}
for (int i = 0; i < k; i++) {
res *= (double)(n - i);
res /= (double)(k - i);
}
return res;
}
int main() {
// cout << fixed << setprecision(12);
string s, t;
cin >> s >> t;
ll ca = 0;
ll cb = 0;
ll n = s.size();
ll a[n] = {};
ll b[30] = {};
char q;
rep(i, n) {
ll k = t.at(i) - 'a';
// cout << k << endl;
a[i] = k;
}
// rep(i,n){
// cout << a[i] << endl;}
rep(i, 30) {
rep(j, n) {
// cout << "i " << i << endl;
if (a[j] == i && ca == 0) {
ca++;
q = s.at(j);
// cout << q << endl;
continue;
}
if ((a[j] == i && s.at(j) != q) || (a[j] != i && s.at(j) == q)) {
cb++;
// cout << i << " " << j << endl;
goto asd;
}
}
ca = 0;
q = '6';
}
asd:
if (cb > 0) {
cout << "No" << endl;
} else {
cout << "Yes" << endl;
}
}
| replace | 41 | 42 | 41 | 42 | 0 | |
p03252 | C++ | Time Limit Exceeded | #include <assert.h>
#include <bits/stdc++.h>
using namespace std;
int main() {
string s, t;
cin >> s >> t;
int size = s.length();
for (int i = 0; i < size; i++)
if (s[i] != t[i]) {
char ts = s[i], tt = t[i];
for (int i = 0; i < size; i++)
if (s[i] == ts)
s[i] = tt;
else if (s[i] == tt)
s[i] = ts;
}
if (s == t)
cout << "Yes" << endl;
else
cout << "No" << endl;
return 0;
}
| #include <assert.h>
#include <bits/stdc++.h>
using namespace std;
int main() {
string s, t;
cin >> s >> t;
bool ok = true;
map<char, char> st, tt;
int size = s.size();
for (int i = 0; i < size; i++) {
if (0 < st.count(s[i]) && st[s[i]] != t[i])
ok = false;
if (0 < tt.count(t[i]) && tt[t[i]] != s[i])
ok = false;
st[s[i]] = t[i];
tt[t[i]] = s[i];
}
cout << (ok ? "Yes" : "No") << endl;
return 0;
}
| replace | 8 | 22 | 8 | 20 | TLE | |
p03252 | Python | Time Limit Exceeded | S = list(input())
T = list(input())
S2, T2 = [], []
for i in S:
S2.append(S.count(i))
for i in T:
T2.append(T.count(i))
if S2 != T2:
print("No")
else:
print("Yes")
| S = list(input())
T = list(input())
S2, T2 = [], []
St, Tt = [], []
for i in range(26):
s = chr(ord("a") + i)
St.append(S.count(s))
Tt.append(T.count(s))
for i in range(len(S)):
S2.append(St[ord(S[i]) - ord("a")])
T2.append(Tt[ord(T[i]) - ord("a")])
if S2 != T2:
print("No")
else:
print("Yes")
| replace | 3 | 7 | 3 | 11 | TLE | |
p03252 | C++ | Runtime Error | #include <cstring>
#include <iostream>
using namespace std;
char a[100000 + 5], b[100000 + 5];
int map1[30], map2[30];
int main() {
scanf("%s", a);
scanf("%s", b);
int n = strlen(a);
for (int i = 0; i < n; i++)
if (map1[a[i] - 'a' + 1] == 0 && map2[b[i] - 'a' + 1] == 0)
map1[a[i] - 'a' + 1] = b[i] - 'a' + 1,
map2[b[i] - 'a' + 1] = a[i] - 'a' + 1;
else {
if ((map1[a[i] - 'a' + 1] != b[i] - 'a' + 1) ||
(map2[b[i] - 'a' + 1] != a[i] - 'a' + 1)) {
printf("No\n");
return 0;
}
}
printf("Yes\n");
}
| #include <cstring>
#include <iostream>
using namespace std;
char a[200000 + 5], b[200000 + 5];
int map1[30], map2[30];
int main() {
scanf("%s", a);
scanf("%s", b);
int n = strlen(a);
for (int i = 0; i < n; i++)
if (map1[a[i] - 'a' + 1] == 0 && map2[b[i] - 'a' + 1] == 0)
map1[a[i] - 'a' + 1] = b[i] - 'a' + 1,
map2[b[i] - 'a' + 1] = a[i] - 'a' + 1;
else {
if ((map1[a[i] - 'a' + 1] != b[i] - 'a' + 1) ||
(map2[b[i] - 'a' + 1] != a[i] - 'a' + 1)) {
printf("No\n");
return 0;
}
}
printf("Yes\n");
}
| replace | 3 | 4 | 3 | 4 | 0 | |
p03252 | C++ | Runtime Error | #include <algorithm>
#include <bitset>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1e9 + 7
#define LINF (long long)4e18
int main() {
string S, T;
cin >> S >> T;
int N = (int)S.size();
vector<pair<char, char>> ST, TS;
rep(i, N) {
ST[i].first = S[i];
ST[i].second = T[i];
TS[i].first = T[i];
TS[i].second = S[i];
}
sort(ST.begin(), ST.end());
sort(TS.begin(), TS.end());
bool ok = true;
rep(i, N - 1) {
if (ST[i].first == ST[i + 1].first) {
if (ST[i].second != ST[i + 1].second)
ok = false;
}
if (TS[i].first == TS[i + 1].first) {
if (TS[i].second != TS[i + 1].second)
ok = false;
}
}
if (ok)
cout << "Yes" << endl;
else
cout << "No" << endl;
} | #include <algorithm>
#include <bitset>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1e9 + 7
#define LINF (long long)4e18
int main() {
string S, T;
cin >> S >> T;
int N = (int)S.size();
vector<pair<char, char>> ST(N), TS(N);
rep(i, N) {
ST[i].first = S[i];
ST[i].second = T[i];
TS[i].first = T[i];
TS[i].second = S[i];
}
sort(ST.begin(), ST.end());
sort(TS.begin(), TS.end());
bool ok = true;
rep(i, N - 1) {
if (ST[i].first == ST[i + 1].first) {
if (ST[i].second != ST[i + 1].second)
ok = false;
}
if (TS[i].first == TS[i + 1].first) {
if (TS[i].second != TS[i + 1].second)
ok = false;
}
}
if (ok)
cout << "Yes" << endl;
else
cout << "No" << endl;
} | replace | 22 | 23 | 22 | 23 | -11 | |
p03252 | C++ | Runtime Error |
#include <bits/stdc++.h>
class kin {
public:
inline void open(FILE *, int);
inline void close(void);
inline void scan(void);
inline kin &operator>(char &);
inline kin &operator>(int &);
inline kin &operator>(long long &);
inline kin &operator>(double &);
inline kin &operator>(long double &);
inline kin &operator>(char *);
template <class T> inline void get(T *, int);
private:
FILE *fp;
char *buf;
int siz;
int idx;
} in;
class kout {
public:
inline void open(FILE *, int);
inline void close(void);
inline void print(void);
inline kout &operator<(char);
inline kout &operator<(int);
inline kout &operator<(long long);
inline kout &operator<(double);
inline kout &operator<(long double);
inline kout &operator<(const char *);
template <class T> inline void put(T *, int, char, char);
private:
FILE *fp;
char *buf;
int siz;
int idx;
} out;
int main(int argc, char **argv) {
in.open(stdin, 512);
out.open(stdout, 512);
in.scan();
char s[100001], t[100001];
in > s > t;
char u[26], v[26];
for (int i = 0; i < 26; ++i)
u[i] = v[i] = '\x00';
int f = 1;
for (int i = 0; s[i]; ++i) {
if (u[s[i] - 'a']) {
if (u[s[i] - 'a'] != t[i]) {
f = 0;
break;
}
} else
u[s[i] - 'a'] = t[i];
if (v[t[i] - 'a']) {
if (v[t[i] - 'a'] != s[i]) {
f = 0;
break;
}
} else
v[t[i] - 'a'] = s[i];
}
out < (f ? "Yes" : "No") < '\n';
out.print();
in.close();
out.close();
return 0;
}
inline void kin::open(FILE *fparg, int sizarg) {
fp = fparg;
buf = new char[sizarg];
siz = sizarg;
idx = 0;
return;
}
inline void kin::close(void) {
fp = nullptr;
delete[] buf;
buf = nullptr;
siz = 0;
idx = 0;
return;
}
inline void kin::scan(void) {
int readsiz =
(int)std::fread((void *)buf, (std::size_t)1, (std::size_t)siz, fp);
if (readsiz != siz)
buf[readsiz] = '\x00';
idx = 0;
return;
}
inline kin &kin::operator>(char &var) {
if (!buf[idx]) {
var = '\x00';
return *this;
}
var = buf[idx];
if (++idx == siz)
scan();
if (++idx == siz)
scan();
return *this;
}
inline kin &kin::operator>(int &var) {
if (!buf[idx]) {
var = 0;
return *this;
}
int sign = -1;
if (buf[idx] == '-') {
sign = 1;
if (++idx == siz)
scan();
}
var = 0;
while (buf[idx] >= '0') {
var = var * 10 - (int)(buf[idx] - '0');
if (++idx == siz)
scan();
}
var *= sign;
if (++idx == siz)
scan();
return *this;
}
inline kin &kin::operator>(long long &var) {
if (!buf[idx]) {
var = 0LL;
return *this;
}
long long sign = -1LL;
if (buf[idx] == '-') {
sign = 1LL;
if (++idx == siz)
scan();
};
var = 0LL;
while (buf[idx] >= '0') {
var = var * 10LL - (long long)(buf[idx] - '0');
if (++idx == siz)
scan();
}
var *= sign;
if (++idx == siz)
scan();
return *this;
}
inline kin &kin::operator>(double &var) {
if (!buf[idx]) {
var = 0.0;
return *this;
}
double sign = -1.0;
if (buf[idx] == '-') {
sign = 1.0;
if (++idx == siz)
scan();
}
var = 0.0;
while (buf[idx] >= '0') {
var = var * 10.0 - (double)(buf[idx] - '0');
if (++idx == siz)
scan();
}
if (buf[idx] == '.') {
if (++idx == siz)
scan();
double dig = 1.0;
while (buf[idx] >= '0') {
var -= (double)(buf[idx] - '0') * (dig /= 10.0);
if (++idx == siz)
scan();
}
}
var *= sign;
if (++idx == siz)
scan();
return *this;
}
inline kin &kin::operator>(long double &var) {
if (!buf[idx]) {
var = 0.0L;
return *this;
}
long double sign = -1.0L;
if (buf[idx] == '-') {
sign = 1.0L;
if (++idx == siz)
scan();
}
var = 0.0L;
while (buf[idx] >= '0') {
var = var * 10.0L - (long double)(buf[idx] - '0');
if (++idx == siz)
scan();
}
if (buf[idx] == '.') {
if (++idx == siz)
scan();
long double dig = 1.0L;
while (buf[idx] >= '0') {
var -= (long double)(buf[idx] - '0') * (dig /= 10.0L);
if (++idx == siz)
scan();
}
}
var *= sign;
if (++idx == siz)
scan();
return *this;
}
inline kin &kin::operator>(char *str) {
if (!buf[idx]) {
str[0] = '\x00';
return *this;
}
int ptr = 0;
while (buf[idx] >= '!') {
str[ptr++] = buf[idx];
if (++idx == siz)
scan();
}
str[ptr] = '\x00';
if (++idx == siz)
scan();
return *this;
}
template <class T> inline void kin::get(T *arr, int num) {
for (int i = 0; i < num; ++i)
(*this) > arr[i];
return;
}
inline void kout::open(FILE *fparg, int sizarg) {
fp = fparg;
buf = new char[sizarg];
siz = sizarg;
idx = 0;
return;
}
inline void kout::close(void) {
fp = nullptr;
delete[] buf;
buf = nullptr;
siz = 0;
idx = 0;
return;
}
inline void kout::print(void) {
std::fwrite((void *)buf, (std::size_t)1, (std::size_t)idx, fp);
idx = 0;
return;
}
inline kout &kout::operator<(char val) {
buf[idx] = val;
if (++idx == siz)
print();
return *this;
}
inline kout &kout::operator<(int val) {
if (val < 0) {
buf[idx] = '-';
if (++idx == siz)
print();
} else
val *= -1;
char dig[10];
int ptr = 0;
do {
int tmp = val / 10;
dig[ptr++] = (char)-(val - tmp * 10) + '0';
val = tmp;
} while (val);
while (ptr--) {
buf[idx] = dig[ptr];
if (++idx == siz)
print();
}
return *this;
}
inline kout &kout::operator<(long long val) {
if (val < 0LL) {
buf[idx] = '-';
if (++idx == siz)
print();
} else
val *= -1LL;
char dig[19];
int ptr = 0;
do {
long long tmp = val / 10LL;
dig[ptr++] = (char)-(val - tmp * 10LL) + '0';
val = tmp;
} while (val);
while (ptr--) {
buf[idx] = dig[ptr];
if (++idx == siz)
print();
}
return *this;
}
inline kout &kout::operator<(double val) {
if (val < 0.0) {
buf[idx] = '-';
if (++idx == siz)
print();
} else
val *= -1.0;
double dig = 1.0;
while (val / dig <= -10.0)
dig *= 10.0;
int tmp;
while (dig >= 1.0) {
buf[idx] = (char)-(tmp = (int)(val / dig)) + '0';
if (++idx == siz)
print();
val -= (double)tmp * dig;
dig /= 10.0;
}
buf[idx] = '.';
if (++idx == siz)
print();
for (int i = 0; i < 12; ++i) {
buf[idx] = (char)-(tmp = (int)(val / dig)) + '0';
if (++idx == siz)
print();
val -= (double)tmp * dig;
dig /= 10.0;
}
return *this;
}
inline kout &kout::operator<(long double val) {
if (val < 0.0L) {
buf[idx] = '-';
if (++idx == siz)
print();
} else
val *= -1.0L;
long double dig = 1.0L;
while (val / dig <= -10.0L)
dig *= 10.0L;
int tmp;
while (dig >= 1.0L) {
buf[idx] = (char)-(tmp = (int)(val / dig)) + '0';
if (++idx == siz)
print();
val -= (long double)tmp * dig;
dig /= 10.0L;
}
buf[idx] = '.';
if (++idx == siz)
print();
for (int i = 0; i < 16; ++i) {
buf[idx] = (char)-(tmp = (int)(val / dig)) + '0';
if (++idx == siz)
print();
val -= (long double)tmp * dig;
dig /= 10.0L;
}
return *this;
}
inline kout &kout::operator<(const char *str) {
for (int i = 0; str[i]; ++i) {
buf[idx] = str[i];
if (++idx == siz)
print();
}
return *this;
}
template <class T> inline void kout::put(T *arr, int num, char dlm, char end) {
--num;
for (int i = 0; i < num; ++i)
(*this) < arr[i] < dlm;
(*this) < arr[num] < end;
return;
}
|
#include <bits/stdc++.h>
class kin {
public:
inline void open(FILE *, int);
inline void close(void);
inline void scan(void);
inline kin &operator>(char &);
inline kin &operator>(int &);
inline kin &operator>(long long &);
inline kin &operator>(double &);
inline kin &operator>(long double &);
inline kin &operator>(char *);
template <class T> inline void get(T *, int);
private:
FILE *fp;
char *buf;
int siz;
int idx;
} in;
class kout {
public:
inline void open(FILE *, int);
inline void close(void);
inline void print(void);
inline kout &operator<(char);
inline kout &operator<(int);
inline kout &operator<(long long);
inline kout &operator<(double);
inline kout &operator<(long double);
inline kout &operator<(const char *);
template <class T> inline void put(T *, int, char, char);
private:
FILE *fp;
char *buf;
int siz;
int idx;
} out;
int main(int argc, char **argv) {
in.open(stdin, 512);
out.open(stdout, 512);
in.scan();
char s[200001], t[200001];
in > s > t;
char u[26], v[26];
for (int i = 0; i < 26; ++i)
u[i] = v[i] = '\x00';
int f = 1;
for (int i = 0; s[i]; ++i) {
if (u[s[i] - 'a']) {
if (u[s[i] - 'a'] != t[i]) {
f = 0;
break;
}
} else
u[s[i] - 'a'] = t[i];
if (v[t[i] - 'a']) {
if (v[t[i] - 'a'] != s[i]) {
f = 0;
break;
}
} else
v[t[i] - 'a'] = s[i];
}
out < (f ? "Yes" : "No") < '\n';
out.print();
in.close();
out.close();
return 0;
}
inline void kin::open(FILE *fparg, int sizarg) {
fp = fparg;
buf = new char[sizarg];
siz = sizarg;
idx = 0;
return;
}
inline void kin::close(void) {
fp = nullptr;
delete[] buf;
buf = nullptr;
siz = 0;
idx = 0;
return;
}
inline void kin::scan(void) {
int readsiz =
(int)std::fread((void *)buf, (std::size_t)1, (std::size_t)siz, fp);
if (readsiz != siz)
buf[readsiz] = '\x00';
idx = 0;
return;
}
inline kin &kin::operator>(char &var) {
if (!buf[idx]) {
var = '\x00';
return *this;
}
var = buf[idx];
if (++idx == siz)
scan();
if (++idx == siz)
scan();
return *this;
}
inline kin &kin::operator>(int &var) {
if (!buf[idx]) {
var = 0;
return *this;
}
int sign = -1;
if (buf[idx] == '-') {
sign = 1;
if (++idx == siz)
scan();
}
var = 0;
while (buf[idx] >= '0') {
var = var * 10 - (int)(buf[idx] - '0');
if (++idx == siz)
scan();
}
var *= sign;
if (++idx == siz)
scan();
return *this;
}
inline kin &kin::operator>(long long &var) {
if (!buf[idx]) {
var = 0LL;
return *this;
}
long long sign = -1LL;
if (buf[idx] == '-') {
sign = 1LL;
if (++idx == siz)
scan();
};
var = 0LL;
while (buf[idx] >= '0') {
var = var * 10LL - (long long)(buf[idx] - '0');
if (++idx == siz)
scan();
}
var *= sign;
if (++idx == siz)
scan();
return *this;
}
inline kin &kin::operator>(double &var) {
if (!buf[idx]) {
var = 0.0;
return *this;
}
double sign = -1.0;
if (buf[idx] == '-') {
sign = 1.0;
if (++idx == siz)
scan();
}
var = 0.0;
while (buf[idx] >= '0') {
var = var * 10.0 - (double)(buf[idx] - '0');
if (++idx == siz)
scan();
}
if (buf[idx] == '.') {
if (++idx == siz)
scan();
double dig = 1.0;
while (buf[idx] >= '0') {
var -= (double)(buf[idx] - '0') * (dig /= 10.0);
if (++idx == siz)
scan();
}
}
var *= sign;
if (++idx == siz)
scan();
return *this;
}
inline kin &kin::operator>(long double &var) {
if (!buf[idx]) {
var = 0.0L;
return *this;
}
long double sign = -1.0L;
if (buf[idx] == '-') {
sign = 1.0L;
if (++idx == siz)
scan();
}
var = 0.0L;
while (buf[idx] >= '0') {
var = var * 10.0L - (long double)(buf[idx] - '0');
if (++idx == siz)
scan();
}
if (buf[idx] == '.') {
if (++idx == siz)
scan();
long double dig = 1.0L;
while (buf[idx] >= '0') {
var -= (long double)(buf[idx] - '0') * (dig /= 10.0L);
if (++idx == siz)
scan();
}
}
var *= sign;
if (++idx == siz)
scan();
return *this;
}
inline kin &kin::operator>(char *str) {
if (!buf[idx]) {
str[0] = '\x00';
return *this;
}
int ptr = 0;
while (buf[idx] >= '!') {
str[ptr++] = buf[idx];
if (++idx == siz)
scan();
}
str[ptr] = '\x00';
if (++idx == siz)
scan();
return *this;
}
template <class T> inline void kin::get(T *arr, int num) {
for (int i = 0; i < num; ++i)
(*this) > arr[i];
return;
}
inline void kout::open(FILE *fparg, int sizarg) {
fp = fparg;
buf = new char[sizarg];
siz = sizarg;
idx = 0;
return;
}
inline void kout::close(void) {
fp = nullptr;
delete[] buf;
buf = nullptr;
siz = 0;
idx = 0;
return;
}
inline void kout::print(void) {
std::fwrite((void *)buf, (std::size_t)1, (std::size_t)idx, fp);
idx = 0;
return;
}
inline kout &kout::operator<(char val) {
buf[idx] = val;
if (++idx == siz)
print();
return *this;
}
inline kout &kout::operator<(int val) {
if (val < 0) {
buf[idx] = '-';
if (++idx == siz)
print();
} else
val *= -1;
char dig[10];
int ptr = 0;
do {
int tmp = val / 10;
dig[ptr++] = (char)-(val - tmp * 10) + '0';
val = tmp;
} while (val);
while (ptr--) {
buf[idx] = dig[ptr];
if (++idx == siz)
print();
}
return *this;
}
inline kout &kout::operator<(long long val) {
if (val < 0LL) {
buf[idx] = '-';
if (++idx == siz)
print();
} else
val *= -1LL;
char dig[19];
int ptr = 0;
do {
long long tmp = val / 10LL;
dig[ptr++] = (char)-(val - tmp * 10LL) + '0';
val = tmp;
} while (val);
while (ptr--) {
buf[idx] = dig[ptr];
if (++idx == siz)
print();
}
return *this;
}
inline kout &kout::operator<(double val) {
if (val < 0.0) {
buf[idx] = '-';
if (++idx == siz)
print();
} else
val *= -1.0;
double dig = 1.0;
while (val / dig <= -10.0)
dig *= 10.0;
int tmp;
while (dig >= 1.0) {
buf[idx] = (char)-(tmp = (int)(val / dig)) + '0';
if (++idx == siz)
print();
val -= (double)tmp * dig;
dig /= 10.0;
}
buf[idx] = '.';
if (++idx == siz)
print();
for (int i = 0; i < 12; ++i) {
buf[idx] = (char)-(tmp = (int)(val / dig)) + '0';
if (++idx == siz)
print();
val -= (double)tmp * dig;
dig /= 10.0;
}
return *this;
}
inline kout &kout::operator<(long double val) {
if (val < 0.0L) {
buf[idx] = '-';
if (++idx == siz)
print();
} else
val *= -1.0L;
long double dig = 1.0L;
while (val / dig <= -10.0L)
dig *= 10.0L;
int tmp;
while (dig >= 1.0L) {
buf[idx] = (char)-(tmp = (int)(val / dig)) + '0';
if (++idx == siz)
print();
val -= (long double)tmp * dig;
dig /= 10.0L;
}
buf[idx] = '.';
if (++idx == siz)
print();
for (int i = 0; i < 16; ++i) {
buf[idx] = (char)-(tmp = (int)(val / dig)) + '0';
if (++idx == siz)
print();
val -= (long double)tmp * dig;
dig /= 10.0L;
}
return *this;
}
inline kout &kout::operator<(const char *str) {
for (int i = 0; str[i]; ++i) {
buf[idx] = str[i];
if (++idx == siz)
print();
}
return *this;
}
template <class T> inline void kout::put(T *arr, int num, char dlm, char end) {
--num;
for (int i = 0; i < num; ++i)
(*this) < arr[i] < dlm;
(*this) < arr[num] < end;
return;
}
| replace | 47 | 48 | 47 | 48 | 0 | |
p03252 | C++ | Time Limit Exceeded |
#include <algorithm>
#include <functional>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
string str1, str2;
cin >> str1 >> str2;
bool flag = true;
for (int i = 0; i < str1.size(); ++i) {
// str1[0]
for (int ii = i; ii < str1.size(); ++ii) {
if (str1[i] == str1[ii]) {
if (str2[i] != str2[ii]) {
flag = false;
}
}
if (str2[i] == str2[ii]) {
if (str1[i] != str1[ii]) {
flag = false;
}
}
}
}
if (flag) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
return 0;
} |
#include <algorithm>
#include <functional>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
string str1, str2;
cin >> str1 >> str2;
bool flag = true;
vector<vector<int>> c1, c2;
for (char a = 'a'; a <= 'z'; ++a) {
vector<int> tmp1, tmp2;
std::string::iterator itr = str1.begin();
while (true) {
itr = find(itr + 1, str1.end(), a);
if (itr == str1.end())
break;
tmp1.push_back(distance(str1.begin(), itr));
}
itr = str2.begin();
while (true) {
itr = find(itr + 1, str2.end(), a);
if (itr == str2.end())
break;
tmp2.push_back(distance(str2.begin(), itr));
}
c1.push_back(tmp1);
c2.push_back(tmp2);
}
for (int i = 0; i < c1.size(); ++i) {
if (find(c1.begin(), c1.end(), c2[i]) == c1.end()) {
flag = false;
}
}
if (flag) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
return 0;
} | replace | 11 | 24 | 11 | 34 | TLE | |
p03252 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG_MODE
#define DBG(n) n;
#else
#define DBG(n) ;
#endif
#define REP(i, n) for (ll(i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v, n) \
{ \
for (int W = 0; W < (n); W++) \
cerr << v[W] << ' '; \
cerr << endl << endl; \
}
#define SHOW2d(v, i, j) \
{ \
for (int aaa = 0; aaa < i; aaa++) { \
for (int bbb = 0; bbb < j; bbb++) \
cerr << v[aaa][bbb] << ' '; \
cerr << endl; \
} \
cerr << endl; \
}
#define ALL(v) v.begin(), v.end()
#define Decimal fixed << setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll, ll> P;
vector<vector<char>> v(26);
vector<vector<char>> vv(26);
int main() {
string a, b;
cin >> a >> b;
REP(i, a.size()) {
v[b[i] - 'a'].PB(a[i]);
vv[a[i] - 'a'].PB(b[i]);
}
REP(i, 26) {
set<char> s;
REP(j, v[i].size()) s.insert(v[i][j]);
if (s.size() > 1) {
cout << "No" << endl;
return 0;
}
}
REP(i, 26) {
set<char> s;
REP(j, v[i].size()) s.insert(vv[i][j]);
if (s.size() > 1) {
cout << "No" << endl;
return 0;
}
}
cout << "Yes" << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG_MODE
#define DBG(n) n;
#else
#define DBG(n) ;
#endif
#define REP(i, n) for (ll(i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v, n) \
{ \
for (int W = 0; W < (n); W++) \
cerr << v[W] << ' '; \
cerr << endl << endl; \
}
#define SHOW2d(v, i, j) \
{ \
for (int aaa = 0; aaa < i; aaa++) { \
for (int bbb = 0; bbb < j; bbb++) \
cerr << v[aaa][bbb] << ' '; \
cerr << endl; \
} \
cerr << endl; \
}
#define ALL(v) v.begin(), v.end()
#define Decimal fixed << setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll, ll> P;
vector<vector<char>> v(26);
vector<vector<char>> vv(26);
int main() {
string a, b;
cin >> a >> b;
REP(i, a.size()) {
v[b[i] - 'a'].PB(a[i]);
vv[a[i] - 'a'].PB(b[i]);
}
REP(i, 26) {
set<char> s;
REP(j, v[i].size()) s.insert(v[i][j]);
if (s.size() > 1) {
cout << "No" << endl;
return 0;
}
}
REP(i, 26) {
set<char> s;
REP(j, vv[i].size()) s.insert(vv[i][j]);
if (s.size() > 1) {
cout << "No" << endl;
return 0;
}
}
cout << "Yes" << endl;
return 0;
} | replace | 61 | 62 | 61 | 62 | -11 | |
p03252 | C++ | Runtime Error | #include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#define ll long long
#define rep(i, s, n) for (int i = s; i < n; i++)
using namespace std;
int main() {
string s, t;
cin >> s >> t;
vector<int> s_count(s.size(), 0);
vector<int> t_count(t.size(), 0);
rep(i, 0, s.size()) {
s_count[s[i] - 'a']++;
t_count[t[i] - 'a']++;
}
sort(s_count.begin(), s_count.end());
sort(t_count.begin(), t_count.end());
rep(i, 0, s_count.size()) {
if (s_count[i] == t_count[i]) {
} else {
cout << "No" << endl;
return 0;
}
}
cout << "Yes" << endl;
return 0;
} | #include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#define ll long long
#define rep(i, s, n) for (int i = s; i < n; i++)
using namespace std;
int main() {
string s, t;
cin >> s >> t;
vector<int> s_count(26, 0);
vector<int> t_count(26, 0);
rep(i, 0, s.size()) {
s_count[s[i] - 'a']++;
t_count[t[i] - 'a']++;
}
sort(s_count.begin(), s_count.end());
sort(t_count.begin(), t_count.end());
rep(i, 0, s_count.size()) {
if (s_count[i] == t_count[i]) {
} else {
cout << "No" << endl;
return 0;
}
}
cout << "Yes" << endl;
return 0;
} | replace | 12 | 14 | 12 | 14 | 0 | |
p03252 | C++ | Time Limit Exceeded | #include <iostream>
#include <string>
#include <vector>
using namespace std;
string get_format(string s) {
vector<char> v;
string f;
for (int i = 0; i < s.size(); i++) {
int j;
for (j = 0; j < v.size(); j++) {
if (s[i] == v[j]) {
// 大文字で表す
f.push_back('A' + j);
}
}
if (j == v.size()) {
v.push_back(s[i]);
f.push_back('A' + j);
}
}
return f;
}
int main() {
string s, t;
cin >> s >> t;
string sf = get_format(s);
string tf = get_format(t);
if (sf == tf)
cout << "Yes";
else
cout << "No";
return 0;
}
| #include <iostream>
#include <string>
#include <vector>
using namespace std;
string get_format(string s) {
vector<char> v;
string f;
for (int i = 0; i < s.size(); i++) {
int j;
for (j = 0; j < v.size(); j++) {
if (s[i] == v[j]) {
// 大文字で表す
f.push_back('A' + j);
break;
}
}
if (j == v.size()) {
v.push_back(s[i]);
f.push_back('A' + j);
}
}
return f;
}
int main() {
string s, t;
cin >> s >> t;
string sf = get_format(s);
string tf = get_format(t);
if (sf == tf)
cout << "Yes";
else
cout << "No";
return 0;
}
| insert | 16 | 16 | 16 | 17 | TLE | |
p03252 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
int main() {
string s, t;
cin >> s >> t;
vector<bool> used(s.size(), false);
for (int i = 0; i < t.size(); i++) {
if (!used[i]) {
for (int j = i + 1; j < t.size(); j++) {
if (s[i] == s[j] && t[i] == t[j])
used[i] = true;
else if ((s[i] == s[j] && t[i] != t[j]) ||
(s[i] != s[j] && t[i] == t[j])) {
cout << "No";
return 0;
}
}
}
}
cout << "Yes\n";
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
string s, t;
cin >> s >> t;
vector<bool> used(s.size(), false);
for (int i = 0; i < t.size(); i++) {
if (!used[i]) {
for (int j = i + 1; j < t.size(); j++) {
if (s[i] == s[j] && t[i] == t[j])
used[j] = true;
else if ((s[i] == s[j] && t[i] != t[j]) ||
(s[i] != s[j] && t[i] == t[j])) {
cout << "No";
return 0;
}
}
}
}
cout << "Yes\n";
return 0;
}
| replace | 10 | 11 | 10 | 11 | TLE | |
p03252 | C++ | Runtime Error | #include <algorithm>
#include <climits>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define P pair<int, int>
#define debug(x) cout << #x << ": " << x << ", "
#define debugln(x) cout << #x << ": " << x << '\n'
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
string s, t;
cin >> s >> t;
int n = s.size();
vector<int> cnt1(26), cnt2(26);
rep(i, n) {
cnt1.at(s.at(i) - 'a')++;
cnt2.at(t.at(i) - 'a')++;
}
rep(i, n) {
if (cnt1.at(s.at(i)) != cnt2.at(t.at(i))) {
cout << "No" << endl;
return 0;
}
}
sort(cnt1.begin(), cnt1.end());
sort(cnt2.begin(), cnt2.end());
if (cnt1 == cnt2) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
} | #include <algorithm>
#include <climits>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define P pair<int, int>
#define debug(x) cout << #x << ": " << x << ", "
#define debugln(x) cout << #x << ": " << x << '\n'
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
string s, t;
cin >> s >> t;
int n = s.size();
vector<int> cnt1(26), cnt2(26);
rep(i, n) {
cnt1.at(s.at(i) - 'a')++;
cnt2.at(t.at(i) - 'a')++;
}
rep(i, n) {
if (cnt1.at(s.at(i) - 'a') != cnt2.at(t.at(i) - 'a')) {
cout << "No" << endl;
return 0;
}
}
sort(cnt1.begin(), cnt1.end());
sort(cnt2.begin(), cnt2.end());
if (cnt1 == cnt2) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
} | replace | 36 | 37 | 36 | 37 | -6 | terminate called after throwing an instance of 'std::out_of_range'
what(): vector::_M_range_check: __n (which is 97) >= this->size() (which is 26)
|
p03252 | C++ | Runtime Error |
#include <bits/stdc++.h>
using namespace std;
#define rep(i, x) for (__typeof(x) i = 0; i < x; i++)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define sci(x) \
int x; \
scanf("%d", &x);
#define scii(x, y) \
int x, y; \
scanf("%d %d", &x, &y);
#define sciii(x, y, z) \
int x, y, z; \
scanf("%d %d %d", &x, &y, &z);
#define TC(x) \
sci(x); \
while (x--)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define debug(x) \
{ cerr << #x << " = " << x << endl; }
#define repi(i, x) for (__typeof(x) i = x - 1; i >= 0; i--)
#define fore(itr, x) \
for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr++)
#define forei(itr, x) \
for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr--)
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vector<int>> vvi;
const int infi = numeric_limits<int>::max();
const double eps = 0;
const int ms = 0;
bool func(const vi &a, const vi &b) {
rep(k, a.size()) {
if (a[k] != b[k])
return false;
}
return true;
}
int main() {
ios::sync_with_stdio(false); // endl->"\n"
cin.tie(0);
string s, t;
cin >> s >> t;
vvi a(26, vi(0)), b(26, vi(0));
int n = s.size();
rep(i, n) {
a[s[i] - 'a'].pb(i);
b[t[i] - 'a'].pb(i);
}
// rep(j, 26)debug(a[j].size())
rep(i, 26) {
bool f = false;
if (a[i].size() == 0)
continue;
rep(j, 26) {
if (b[j].size() == 0 || a[i].size() != b[j].size())
continue;
if (func(a[i], a[j])) {
f = true;
break;
}
}
if (!f) {
cout << "No"
<< "\n";
return 0;
}
}
cout << "Yes"
<< "\n";
return 0;
} |
#include <bits/stdc++.h>
using namespace std;
#define rep(i, x) for (__typeof(x) i = 0; i < x; i++)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define sci(x) \
int x; \
scanf("%d", &x);
#define scii(x, y) \
int x, y; \
scanf("%d %d", &x, &y);
#define sciii(x, y, z) \
int x, y, z; \
scanf("%d %d %d", &x, &y, &z);
#define TC(x) \
sci(x); \
while (x--)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define debug(x) \
{ cerr << #x << " = " << x << endl; }
#define repi(i, x) for (__typeof(x) i = x - 1; i >= 0; i--)
#define fore(itr, x) \
for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr++)
#define forei(itr, x) \
for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr--)
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vector<int>> vvi;
const int infi = numeric_limits<int>::max();
const double eps = 0;
const int ms = 0;
bool func(const vi &a, const vi &b) {
rep(k, a.size()) {
if (a[k] != b[k])
return false;
}
return true;
}
int main() {
ios::sync_with_stdio(false); // endl->"\n"
cin.tie(0);
string s, t;
cin >> s >> t;
vvi a(26, vi(0)), b(26, vi(0));
int n = s.size();
rep(i, n) {
a[s[i] - 'a'].pb(i);
b[t[i] - 'a'].pb(i);
}
// rep(j, 26)debug(a[j].size())
rep(i, 26) {
bool f = false;
if (a[i].size() == 0)
continue;
rep(j, 26) {
if (b[j].size() == 0 || a[i].size() != b[j].size())
continue;
if (func(a[i], b[j])) {
f = true;
break;
}
}
if (!f) {
cout << "No"
<< "\n";
return 0;
}
}
cout << "Yes"
<< "\n";
return 0;
}
| replace | 75 | 76 | 75 | 76 | -11 | |
p03252 | C++ | Time Limit Exceeded | #include <iostream>
#include <map>
#include <string>
int main() {
std::string S, T;
std::map<char, char> m, mr;
std::cin >> S >> T;
for (int i = 0; i < S.size(); ++i) {
if (S[i] == T[i])
continue;
auto s = S[i];
auto t = T[i];
for (auto it = S.begin(), end = S.end(); it != end; ++it) {
if (*it == s)
*it = t;
else if (*it == t)
*it = s;
}
}
if (S == T)
std::cout << "Yes\n";
else
std::cout << "No\n";
} | #include <iostream>
#include <map>
#include <string>
int main() {
std::string S, T;
std::map<char, char> m, mr;
std::cin >> S >> T;
for (int i = 0; i < T.size(); ++i) {
auto t = T[i];
auto s = S[i];
auto it = m.find(t);
if (it != m.end() && it->second != s) {
std::cout << "No\n";
exit(0);
}
it = mr.find(s);
if (it != mr.end() && it->second != t) {
std::cout << "No\n";
exit(0);
}
m[t] = s;
mr[s] = t;
}
S.clear();
T.clear();
for (auto it = m.begin(), end = m.end(); it != end; ++it) {
S.append(1, it->first);
T.append(1, it->second);
}
for (int i = 0; i < S.size(); ++i) {
if (S[i] == T[i])
continue;
auto s = S[i];
auto t = T[i];
for (auto it = S.begin(), end = S.end(); it != end; ++it) {
if (*it == s)
*it = t;
else if (*it == t)
*it = s;
}
}
if (S == T)
std::cout << "Yes\n";
else
std::cout << "No\n";
} | insert | 8 | 8 | 8 | 31 | TLE | |
p03252 | C++ | Time Limit Exceeded | #include <iostream>
#include <stdio.h>
// #include <bits/stdc++.h>
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cmath>
#include <cstdint>
#include <cstring>
#include <float.h>
#include <iomanip>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#define INF 1e9
#define rep(i, n) for (int i = 0; (i) < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); (i) <= (int)(b); i++)
#define VEC(type, c, n) \
std::vector<type> c(n); \
for (auto &i : c) \
std::cin >> i;
#define vec(type, n) vector<type>(n)
#define vvec(m, n) vector<vector<int>>(int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int, int>;
vector<int> bitSearch(int bit, int n) {
vector<int> S;
rep(i, n) if (bit & (1 << i)) S.push_back(i);
return S;
}
int main() {
string s, t;
cin >> s >> t;
vector<vector<int>> ss(26);
vector<vector<int>> tt(26);
int n = s.size();
rep(i, n) {
ss[s[i] - 'a'].push_back(i);
tt[t[i] - 'a'].push_back(i);
}
bool f = true;
rep(i, n) {
if (ss[s[i] - 'a'] != tt[t[i] - 'a'])
f = false;
}
cout << (f ? "Yes" : "No");
}
| #include <iostream>
#include <stdio.h>
// #include <bits/stdc++.h>
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cmath>
#include <cstdint>
#include <cstring>
#include <float.h>
#include <iomanip>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#define INF 1e9
#define rep(i, n) for (int i = 0; (i) < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); (i) <= (int)(b); i++)
#define VEC(type, c, n) \
std::vector<type> c(n); \
for (auto &i : c) \
std::cin >> i;
#define vec(type, n) vector<type>(n)
#define vvec(m, n) vector<vector<int>>(int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int, int>;
vector<int> bitSearch(int bit, int n) {
vector<int> S;
rep(i, n) if (bit & (1 << i)) S.push_back(i);
return S;
}
int main() {
string s, t;
cin >> s >> t;
vector<vector<int>> ss(26);
vector<vector<int>> tt(26);
int n = s.size();
rep(i, n) {
ss[s[i] - 'a'].push_back(i);
tt[t[i] - 'a'].push_back(i);
}
bool f = true;
rep(i, n) {
if (ss[s[i] - 'a'].size() != tt[t[i] - 'a'].size())
f = false;
}
cout << (f ? "Yes" : "No");
}
| replace | 53 | 54 | 53 | 54 | TLE | |
p03252 | C++ | Runtime Error | /**
* File : C.cpp
* Author : Kazune Takahashi
* Created : 2018-9-23 21:07:54
* Powered by Visual Studio Code
*/
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
#include <complex>
#include <functional>
#include <iomanip> // << fixed << setprecision(xxx)
#include <iostream>
#include <map> // if (M.find(key) != M.end()) { }
#include <queue>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(19920725));
#include <set>
#include <stack>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <tuple>
#include <vector>
// start = std::chrono::system_clock::now();
// double elapsed =
// std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;
#define DEBUG 0 // change 0 -> 1 if we need debug.
typedef long long ll;
// const int dx[4] = {1, 0, -1, 0};
// const int dy[4] = {0, 1, 0, -1};
// const int C = 1e6+10;
// const ll M = 1000000007;
set<int> to[26];
set<int> from[26];
string S, T;
int main() {
cin >> S >> T;
int N = S.size();
for (auto i = 0; i < N; i++) {
int x = S[i] - 'a';
int y = T[i] - 'a';
to[x].insert(y);
from[y].insert(x);
}
for (auto i = 0; i < N; i++) {
if (to[i].size() > 1 || from[i].size() > 1) {
cout << "No" << endl;
return 0;
}
}
cout << "Yes" << endl;
} | /**
* File : C.cpp
* Author : Kazune Takahashi
* Created : 2018-9-23 21:07:54
* Powered by Visual Studio Code
*/
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
#include <complex>
#include <functional>
#include <iomanip> // << fixed << setprecision(xxx)
#include <iostream>
#include <map> // if (M.find(key) != M.end()) { }
#include <queue>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(19920725));
#include <set>
#include <stack>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <tuple>
#include <vector>
// start = std::chrono::system_clock::now();
// double elapsed =
// std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;
#define DEBUG 0 // change 0 -> 1 if we need debug.
typedef long long ll;
// const int dx[4] = {1, 0, -1, 0};
// const int dy[4] = {0, 1, 0, -1};
// const int C = 1e6+10;
// const ll M = 1000000007;
set<int> to[26];
set<int> from[26];
string S, T;
int main() {
cin >> S >> T;
int N = S.size();
for (auto i = 0; i < N; i++) {
int x = S[i] - 'a';
int y = T[i] - 'a';
to[x].insert(y);
from[y].insert(x);
}
for (auto i = 0; i < 26; i++) {
if (to[i].size() > 1 || from[i].size() > 1) {
cout << "No" << endl;
return 0;
}
}
cout << "Yes" << endl;
} | replace | 54 | 55 | 54 | 55 | 0 | |
p03252 | C++ | Runtime Error | #include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// #pragma GCC optimize("Ofast")
// #define _GLIBCXX_DEBUG
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
// #define int ll
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) \
typ var; \
cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
struct io {
io() {
ios::sync_with_stdio(false);
cin.tie(0);
}
};
const int INF = INT_MAX / 2;
const ll LLINF = 1LL << 60;
constexpr ll MOD = 1000000007;
const double EPS = 1e-9;
signed main(void) {
cin.tie(0);
ios::sync_with_stdio(false);
string S, T;
cin >> S >> T;
// hash
vvi posS(26, vi());
for (int i = 0; i < S.size(); i++) {
posS[S[i] - 'a'].push_back(i);
}
vi oks(26);
// すべて同じ & 2回目出てこない
for (int s = 0; s < S.size(); s++) {
vi &v = posS[s];
if (v.size() > 0) {
char c = T[v[0]] - 'a';
if (oks[c]) {
fin("No");
return 0;
}
for (int ss = 1; ss < v.size(); ss++) {
if (T[v[ss]] - 'a' != c) {
fin("No");
return 0;
}
}
oks[c] = 1;
}
}
fin("Yes");
} | #include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// #pragma GCC optimize("Ofast")
// #define _GLIBCXX_DEBUG
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
// #define int ll
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) \
typ var; \
cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
struct io {
io() {
ios::sync_with_stdio(false);
cin.tie(0);
}
};
const int INF = INT_MAX / 2;
const ll LLINF = 1LL << 60;
constexpr ll MOD = 1000000007;
const double EPS = 1e-9;
signed main(void) {
cin.tie(0);
ios::sync_with_stdio(false);
string S, T;
cin >> S >> T;
// hash
vvi posS(26, vi());
for (int i = 0; i < S.size(); i++) {
posS[S[i] - 'a'].push_back(i);
}
vi oks(26);
// すべて同じ & 2回目出てこない
for (int s = 0; s < posS.size(); s++) {
vi &v = posS[s];
if (v.size() > 0) {
char c = T[v[0]] - 'a';
if (oks[c]) {
fin("No");
return 0;
}
for (int ss = 1; ss < v.size(); ss++) {
if (T[v[ss]] - 'a' != c) {
fin("No");
return 0;
}
}
oks[c] = 1;
}
}
fin("Yes");
} | replace | 98 | 99 | 98 | 99 | 0 | |
p03252 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
// #define INF 10000000000000009
#define INF 9223372036854775807
typedef long long ll;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define OREP(i, n) for (int i = 1; i <= (n); ++i)
#define ORREP(i, n) for (int i = (n); i >= 1; --i)
#define ZREP(i, n) for (int i = 1; i < (n); ++i)
#define RREP(i, n) for (int i = (n)-1; i >= 0; --i)
#define rollcall cout << "I'm Sucu." << endl;
#define YES(s) s ? cout << "YES" << endl : cout << "NO" << endl
#define Yes(s) s ? cout << "Yes" << endl : cout << "No" << endl
#define Taka(s) s ? cout << "Takahashi" << endl : cout << "Aoki" << endl
#define out(s, t, u) s ? cout << t << endl : cout << u << endl
#define int ll
#define Endl endl
int UF[114514];
int UF2[114514];
void UFinit(int n) {
for (int i = 0; i <= n; i++) {
UF[i] = i;
}
}
int UFroot(int k) {
if (UF[k] == k) {
return k;
} else {
UF[k] = UFroot(UF[k]);
return UF[k];
}
}
int UFsame(int P, int Q) {
if (UFroot(P) == UFroot(Q)) {
return true;
} else {
return false;
}
}
void UFunite(int P, int Q) {
int p = UFroot(P);
int q = UFroot(Q);
if (p == q)
return;
if (p > q)
swap(p, q);
UF[q] = p;
}
signed main() {
string S, T;
cin >> S >> T;
int E[26];
UFinit(S.size());
REP(i, 26) { E[i] = -1; }
REP(i, S.size()) {
if (E[S[i] - 'a'] == -1) {
E[S[i] - 'a'] = i;
} else {
UFunite(E[S[i] - 'a'], i);
}
}
REP(i, S.size()) { UF2[i] = UF[i]; }
UFinit(T.size());
REP(i, 26) { E[i] = -1; }
REP(i, T.size()) {
if (E[T[i] - 'a'] == -1) {
E[T[i] - 'a'] = i;
} else {
UFunite(E[T[i] - 'a'], i);
}
}
/*REP(i,S.size()){
cout << UF2[i] << " ";
}cout << Endl;
REP(i,S.size()){
cout << UF[i] << " ";
}cout << Endl;*/
REP(i, S.size()) {
if (UF[i] != UF2[i]) {
cout << "No" << endl;
return 0;
}
}
cout << "Yes" << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
// #define INF 10000000000000009
#define INF 9223372036854775807
typedef long long ll;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define OREP(i, n) for (int i = 1; i <= (n); ++i)
#define ORREP(i, n) for (int i = (n); i >= 1; --i)
#define ZREP(i, n) for (int i = 1; i < (n); ++i)
#define RREP(i, n) for (int i = (n)-1; i >= 0; --i)
#define rollcall cout << "I'm Sucu." << endl;
#define YES(s) s ? cout << "YES" << endl : cout << "NO" << endl
#define Yes(s) s ? cout << "Yes" << endl : cout << "No" << endl
#define Taka(s) s ? cout << "Takahashi" << endl : cout << "Aoki" << endl
#define out(s, t, u) s ? cout << t << endl : cout << u << endl
#define int ll
#define Endl endl
int UF[214514];
int UF2[214514];
void UFinit(int n) {
for (int i = 0; i <= n; i++) {
UF[i] = i;
}
}
int UFroot(int k) {
if (UF[k] == k) {
return k;
} else {
UF[k] = UFroot(UF[k]);
return UF[k];
}
}
int UFsame(int P, int Q) {
if (UFroot(P) == UFroot(Q)) {
return true;
} else {
return false;
}
}
void UFunite(int P, int Q) {
int p = UFroot(P);
int q = UFroot(Q);
if (p == q)
return;
if (p > q)
swap(p, q);
UF[q] = p;
}
signed main() {
string S, T;
cin >> S >> T;
int E[26];
UFinit(S.size());
REP(i, 26) { E[i] = -1; }
REP(i, S.size()) {
if (E[S[i] - 'a'] == -1) {
E[S[i] - 'a'] = i;
} else {
UFunite(E[S[i] - 'a'], i);
}
}
REP(i, S.size()) { UF2[i] = UF[i]; }
UFinit(T.size());
REP(i, 26) { E[i] = -1; }
REP(i, T.size()) {
if (E[T[i] - 'a'] == -1) {
E[T[i] - 'a'] = i;
} else {
UFunite(E[T[i] - 'a'], i);
}
}
/*REP(i,S.size()){
cout << UF2[i] << " ";
}cout << Endl;
REP(i,S.size()){
cout << UF[i] << " ";
}cout << Endl;*/
REP(i, S.size()) {
if (UF[i] != UF2[i]) {
cout << "No" << endl;
return 0;
}
}
cout << "Yes" << endl;
return 0;
}
| replace | 19 | 21 | 19 | 21 | 0 | |
p03252 | C++ | Time Limit Exceeded | // #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef map<int, int> mii;
typedef map<char, int> mci;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vii;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define F first
#define S second
#define in insert
const int INF = 1e9 + 7;
int main() {
string s, t;
cin >> s >> t;
vb used(s.size(), false);
for (int i = 0; i < t.size(); i++) {
if (!used[i]) {
for (int j = 0; j < t.size(); j++) {
if (s[j] == s[i] && t[j] == t[i])
used[i] = true;
if (s[j] == s[i] && t[j] != t[i] || s[j] != s[i] && t[j] == t[i]) {
cout << "No";
return 0;
}
}
}
}
cout << "Yes";
} | // #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef map<int, int> mii;
typedef map<char, int> mci;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vii;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define F first
#define S second
#define in insert
const int INF = 1e9 + 7;
int main() {
string s, t;
cin >> s >> t;
vb used(s.size(), false);
for (int i = 0; i < t.size(); i++) {
if (!used[i]) {
for (int j = 0; j < t.size(); j++) {
if (s[j] == s[i] && t[j] == t[i])
used[j] = true;
if (s[j] == s[i] && t[j] != t[i] || s[j] != s[i] && t[j] == t[i]) {
cout << "No";
return 0;
}
}
}
}
cout << "Yes";
} | replace | 29 | 30 | 29 | 30 | TLE | |
p03252 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef vector<int> V;
int main() {
string s, t;
cin >> s >> t;
int a = 1;
map<char, int> mps, mpt;
int sx[200] = {}, tx[200] = {};
for (int i = 0; i < (int)s.size(); i++) {
bool ex = false;
for (auto itr = mps.begin(); itr != mps.end(); itr++) {
if (itr->first == s[i])
ex = true;
}
if (ex)
sx[i] = mps[s[i]];
else {
sx[i] = a;
mps[s[i]] = a;
a++;
}
}
a = 1;
for (int i = 0; i < (int)t.size(); i++) {
bool ex = false;
for (auto itr = mpt.begin(); itr != mpt.end(); itr++) {
if (itr->first == t[i])
ex = true;
}
if (ex)
tx[i] = mpt[t[i]];
else {
tx[i] = a;
mpt[t[i]] = a;
a++;
}
}
bool res = true;
for (int i = 0; i < (int)s.size(); i++) {
// cout << sx[i] << " " << tx[i] << endl;
if (sx[i] != tx[i])
res = false;
}
dump(res ? "Yes" : "No");
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef vector<int> V;
int main() {
string s, t;
cin >> s >> t;
int a = 1;
map<char, int> mps, mpt;
int sx[200005] = {}, tx[200005] = {};
for (int i = 0; i < (int)s.size(); i++) {
bool ex = false;
for (auto itr = mps.begin(); itr != mps.end(); itr++) {
if (itr->first == s[i])
ex = true;
}
if (ex)
sx[i] = mps[s[i]];
else {
sx[i] = a;
mps[s[i]] = a;
a++;
}
}
a = 1;
for (int i = 0; i < (int)t.size(); i++) {
bool ex = false;
for (auto itr = mpt.begin(); itr != mpt.end(); itr++) {
if (itr->first == t[i])
ex = true;
}
if (ex)
tx[i] = mpt[t[i]];
else {
tx[i] = a;
mpt[t[i]] = a;
a++;
}
}
bool res = true;
for (int i = 0; i < (int)s.size(); i++) {
// cout << sx[i] << " " << tx[i] << endl;
if (sx[i] != tx[i])
res = false;
}
dump(res ? "Yes" : "No");
return 0;
}
| replace | 11 | 12 | 11 | 12 | 0 | |
p03252 | C++ | Runtime Error | #include <cmath>
#include <iostream>
using namespace std;
int main() {
string s, t;
cin >> s >> t;
int a[1 << 17], b[1 << 17], l = s.size(), aa[30], bb[30], c = 0, d = 0;
for (int i = 0; i < 28; i++)
aa[i] = bb[i] = -1;
for (int i = 0; i < l; i++) {
if (aa[s[i] - 97] < 0)
a[i] = ++c, aa[s[i] - 97] = i;
else
a[i] = a[aa[s[i] - 97]];
if (bb[t[i] - 97] < 0)
b[i] = ++d, bb[t[i] - 97] = i;
else
b[i] = b[bb[t[i] - 97]];
}
for (int i = 0; i < l; i++) {
if (a[i] != b[i]) {
cout << "No" << endl;
return 0;
}
}
cout << "Yes" << endl;
return 0;
} | #include <cmath>
#include <iostream>
using namespace std;
int main() {
string s, t;
cin >> s >> t;
int a[1 << 18], b[1 << 18], l = s.size(), aa[30], bb[30], c = 0, d = 0;
for (int i = 0; i < 28; i++)
aa[i] = bb[i] = -1;
for (int i = 0; i < l; i++) {
if (aa[s[i] - 97] < 0)
a[i] = ++c, aa[s[i] - 97] = i;
else
a[i] = a[aa[s[i] - 97]];
if (bb[t[i] - 97] < 0)
b[i] = ++d, bb[t[i] - 97] = i;
else
b[i] = b[bb[t[i] - 97]];
}
for (int i = 0; i < l; i++) {
if (a[i] != b[i]) {
cout << "No" << endl;
return 0;
}
}
cout << "Yes" << endl;
return 0;
} | replace | 6 | 7 | 6 | 7 | 0 | |
p03252 | C++ | Runtime Error | #include <cstdio>
#include <cstring>
using namespace std;
char s[100001] = {0};
char sout[100001] = {0};
char t[100001] = {0};
char tout[100001] = {0};
void normalize(char *str, char *strout) {
char d[300] = {0};
char current = 'a';
for (int i = 0; str[i] != '\0'; i++) {
if (d[str[i]] == 0) {
d[str[i]] = current;
current++;
}
strout[i] = d[str[i]];
}
}
int main() {
scanf("%s\n", s);
scanf("%s\n", t);
normalize(s, sout);
normalize(t, tout);
// printf("%s\n", s);
// printf("%s\n", t);
// printf("%s\n", sout);
// printf("%s\n", tout);
if (strcmp(sout, tout) == 0) {
printf("Yes\n");
} else {
printf("No\n");
}
return 0;
}
| #include <cstdio>
#include <cstring>
using namespace std;
char s[1000001] = {0};
char sout[1000001] = {0};
char t[1000001] = {0};
char tout[1000001] = {0};
void normalize(char *str, char *strout) {
char d[300] = {0};
char current = 'a';
for (int i = 0; str[i] != '\0'; i++) {
if (d[str[i]] == 0) {
d[str[i]] = current;
current++;
}
strout[i] = d[str[i]];
}
}
int main() {
scanf("%s\n", s);
scanf("%s\n", t);
normalize(s, sout);
normalize(t, tout);
// printf("%s\n", s);
// printf("%s\n", t);
// printf("%s\n", sout);
// printf("%s\n", tout);
if (strcmp(sout, tout) == 0) {
printf("Yes\n");
} else {
printf("No\n");
}
return 0;
}
| replace | 5 | 9 | 5 | 9 | 0 | |
p03252 | Python | Time Limit Exceeded | S = input()
T = input()
# 例abcdefg...のように文字列が1対1の矢印関係の場合は、
# どのような場合でも置き換えできる。問題は同じ文字が複数現れる場合
# S上に同じ文字sのある場所には
# T上にも同じ文字tがなくてはならない
# つまり、同じ値になっているインデックスの集合を取れば
# 全部同じになっているはず
# 文字種ごとにインデックスの集合を求める
ns = len(S)
indexS = {}
for i in range(ns):
s = S[i]
if s in indexS:
indexS[s].append(i)
else:
indexS[s] = [i]
indexT = {}
for i in range(ns):
t = T[i]
if t in indexT:
indexT[t].append(i)
else:
indexT[t] = [i]
# 先頭の文字から、インデックスの集合が等しいかチェック
for s, t in zip(S, T):
i_s = indexS[s]
i_t = indexT[t]
if i_s != i_t:
print("No")
break
else:
print("Yes")
| S = input()
T = input()
# 例abcdefg...のように文字列が1対1の矢印関係の場合は、
# どのような場合でも置き換えできる。問題は同じ文字が複数現れる場合
# S上に同じ文字sのある場所には
# T上にも同じ文字tがなくてはならない
# つまり、同じ値になっているインデックスの集合を取れば
# 全部同じになっているはず
# 文字種ごとにインデックスの集合を求める
ns = len(S)
indexS = {}
for i in range(ns):
s = S[i]
if s in indexS:
indexS[s].append(i)
else:
indexS[s] = [i]
indexT = {}
for i in range(ns):
t = T[i]
if t in indexT:
indexT[t].append(i)
else:
indexT[t] = [i]
# 先頭の文字から、インデックスの集合が等しいかチェック
for i in range(ns):
s = S[i]
t = T[i]
i_s = len(indexS[s])
i_t = len(indexT[t])
if i_s != i_t:
print("No")
break
else:
print("Yes")
| replace | 28 | 31 | 28 | 33 | TLE | |
p03252 | C++ | Runtime Error | #include "bits/stdc++.h"
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define RREP0(i, n) for (int i = n - 1; i >= 0; --i)
#define RREP1(i, n) for (int i = n; i >= 1; --i)
#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(c) reverse((c).begin(), (c).end())
#define FILL(c, v) fill((c).begin(), (c).end(), v)
#define SZ(a) int((a).size())
#define EXIST(s, e) ((s).find(e) != (s).end())
#define CLR(a) memset((a), 0, sizeof(a))
inline int toInt(string s) {
int v;
istringstream sin(s);
sin >> v;
return v;
}
template <class T> inline string toString(T x) {
ostringstream sout;
sout << x;
return sout.str();
}
typedef long long LL;
typedef unsigned long long ULL;
const int INTINF = 1e9;
const LL LLINF = 1e18;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
void solve() {
vector<int> S_histo(256);
vector<int> T_histo(256);
string S, T;
cin >> S >> T;
REP0(i, S.length()) {
S_histo[(int)(unsigned char)S[i]]++;
T_histo[(int)(unsigned char)T[i]]++;
}
SORT(S_histo);
REVERSE(S_histo);
SORT(T_histo);
REVERSE(T_histo);
bool possible = true;
REP0(i, S.length()) if (S_histo[i] != T_histo[i]) possible = false;
cout << (possible ? "Yes" : "No") << endl;
}
int main(int argc, char const *argv[]) {
cin.tie(0);
ios::sync_with_stdio(false);
std::cout << std::fixed << std::setprecision(10);
solve();
return 0;
} | #include "bits/stdc++.h"
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define RREP0(i, n) for (int i = n - 1; i >= 0; --i)
#define RREP1(i, n) for (int i = n; i >= 1; --i)
#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(c) reverse((c).begin(), (c).end())
#define FILL(c, v) fill((c).begin(), (c).end(), v)
#define SZ(a) int((a).size())
#define EXIST(s, e) ((s).find(e) != (s).end())
#define CLR(a) memset((a), 0, sizeof(a))
inline int toInt(string s) {
int v;
istringstream sin(s);
sin >> v;
return v;
}
template <class T> inline string toString(T x) {
ostringstream sout;
sout << x;
return sout.str();
}
typedef long long LL;
typedef unsigned long long ULL;
const int INTINF = 1e9;
const LL LLINF = 1e18;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
void solve() {
vector<int> S_histo(256);
vector<int> T_histo(256);
string S, T;
cin >> S >> T;
REP0(i, S.length()) {
S_histo[(int)(unsigned char)S[i]]++;
T_histo[(int)(unsigned char)T[i]]++;
}
SORT(S_histo);
REVERSE(S_histo);
SORT(T_histo);
REVERSE(T_histo);
bool possible = true;
REP0(i, 256) if (S_histo[i] != T_histo[i]) possible = false;
cout << (possible ? "Yes" : "No") << endl;
}
int main(int argc, char const *argv[]) {
cin.tie(0);
ios::sync_with_stdio(false);
std::cout << std::fixed << std::setprecision(10);
solve();
return 0;
} | replace | 52 | 53 | 52 | 53 | 0 | |
p03253 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)
typedef long long ll;
#define mod 1000000007
ll mod_pow(ll x, ll n) {
ll res = 1;
while (n != 0) {
if (n & 1)
res = res * x % mod;
x = x * x % mod;
n = n >> 1;
}
return res;
}
ll mod_fact(ll x) {
ll res = 1;
for (ll i = x; i > 0; i--)
res *= i, res %= mod;
return res;
}
ll nCr(ll n, ll r) {
ll nume = mod_fact(n);
ll deno = mod_fact(r) * mod_fact(n - r) % mod;
return nume * mod_pow(deno, mod - 2) % mod;
}
int main() {
int N, M;
cin >> N >> M;
ll ans = 1;
for (int i = 2; i * i <= M; i++) {
ll cnt = 0;
while (M % i == 0) {
M /= i;
cnt++;
}
ans = ans * nCr(N + cnt - 1, cnt) % mod;
}
if (M != 1)
ans = ans * N % mod;
cout << ans << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)
typedef long long ll;
#define mod 1000000007
ll mod_pow(ll x, ll n) {
ll res = 1;
while (n != 0) {
if (n & 1)
res = res * x % mod;
x = x * x % mod;
n = n >> 1;
}
return res;
}
ll mod_fact(ll x) {
ll res = 1;
for (ll i = x; i > 0; i--)
res *= i, res %= mod;
return res;
}
ll nCr(ll n, ll r) {
ll nume = mod_fact(n);
ll deno = mod_fact(r) * mod_fact(n - r) % mod;
return nume * mod_pow(deno, mod - 2) % mod;
}
int main() {
int N, M;
cin >> N >> M;
ll ans = 1;
for (int i = 2; i * i <= M; i++) {
ll cnt = 0;
while (M % i == 0) {
M /= i;
cnt++;
}
if (cnt)
ans = ans * nCr(N + cnt - 1, cnt) % mod;
}
if (M != 1)
ans = ans * N % mod;
cout << ans << endl;
return 0;
}
| replace | 40 | 41 | 40 | 42 | TLE | |
p03253 | C++ | Runtime Error | #include <bits/stdc++.h>
#define r(i, n) for (int i = 0; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> P2;
#define fi first
#define se second
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
typedef long long ll;
struct NT {
ll m; // mod
vector<bool> ismrime;
vector<ll> euler;
vector<ll> fact;
NT(ll MOD) {
m = MOD;
fact.resize(500005);
fact[0] = 1;
for (ll i = 1; i < 500005; i++) {
fact[i] = (fact[i - 1] * i) % MOD;
}
}
void eratos(int n) {
ismrime.resize(n + 1);
for (int i = 0; i <= n; i++)
ismrime[i] = true;
ismrime[0] = 0;
ismrime[1] = 0;
for (int i = 2; i <= n; i++) {
if (ismrime[i]) {
for (int j = i + i; j <= n; j += i)
ismrime[j] = false;
}
}
}
// 因数分解 √N
vector<int> mrime_decommosition(ll x) {
vector<int> res;
for (int i = 2; i * i <= x; i++) {
while (x % i == 0) {
x /= i;
res.push_back(i);
}
}
if (x != 1)
res.push_back(x);
return res;
}
// 約数列挙 √N
vector<ll> divisor(ll x) {
vector<ll> res;
for (ll i = 1; i * i <= x; i++)
if (x % i == 0) {
res.push_back(i);
if (i * i != x)
res.push_back(x / i);
}
sort(res.begin(), res.end());
return res;
}
// a*b>LONG_MAX ?
bool overflow(ll a, ll b, ll LONGMAX) { return a > LONGMAX / b; }
ll extgcd(ll a, ll b, ll &x, ll &y) {
ll d = a;
if (b != 0) {
d = extgcd(b, a % b, y, x);
y -= (a / b) * x;
} else {
x = 1;
y = 0;
}
return d;
}
ll mod_inverse(ll a) {
ll x, y;
extgcd(a, m, x, y);
return (m + x % m) % m;
}
// オイラー関数√N
ll euler_mhi(ll n) {
ll res = n;
for (ll i = 2; i * i <= n; i++) {
if (n % i == 0) {
res = res / i * (i - 1);
for (; n % i == 0; n /= i)
;
}
}
if (n != 1)
res = res / n * (n - 1);
return res;
}
void make_euler_table(int n) {
euler.resize(n + 1);
for (int i = 0; i < n; i++)
euler[i] = i;
for (int i = 2; i < n; i++) {
if (euler[i] == i) {
for (int j = i; j < n; j += i) {
euler[j] = euler[j] / i * (i - 1);
}
}
}
}
// n! と nCr
// mはmod
ll mod_fact(ll n, ll &e) {
e = 0;
if (n == 0)
return 1;
int res = mod_fact(n / m, e);
e += n / m;
if (n / m % 2 != 0)
return res * (m - fact[n % m]) % m;
return res * fact[n % m] % m;
}
ll combination(ll n, ll k) {
if (n == k || k == 0)
return 1;
if (n < 0 || k < 0 || n < k)
return 0;
ll e1, e2, e3;
ll a1 = mod_fact(n, e1);
ll a2 = mod_fact(k, e2);
ll a3 = mod_fact(n - k, e3);
return a1 * mod_inverse(a2 * a3 % m) % m;
}
ll stupid_combination(ll n, ll k) {
if (n == k || k == 0)
return 1;
if (n < 0 || k < 0 || n < k)
return 0;
ll res = 1;
for (ll i = 0; i < k; i++) {
res *= (n - i);
res %= m;
res *= mod_inverse(i + 1);
res %= m;
}
return res;
}
ll mod_mult(ll a, ll b, ll m) {
ll res = 0;
ll exm = a % m;
while (b) {
if (b & 1) {
res += exm;
if (res > m)
res -= m;
}
exm <<= 1;
if (exm > m)
exm -= m;
b >>= 1;
}
return res;
}
ll mod_exm(ll a, ll b, ll m) {
ll res = 1;
ll exm = a % m;
while (b) {
if (b & 1)
res = mod_mult(res, exm, m);
exm = mod_mult(exm, exm, m);
b >>= 1;
}
return res;
}
// 確率的高速素数判定
bool miller_rabin(ll n, ll times = 10) {
if (n < 2)
return false;
if (n == 2)
return true;
if (!(n & 1))
return false;
ll q = n - 1;
int k = 0;
while (q % 2 == 0) {
k++;
q >>= 1;
}
for (int i = 0; i < times; i++) {
ll a = rand() % (n - 1) + 1;
ll x = mod_exm(a, q, n);
if (x == 1)
continue;
bool found = false;
for (int j = 0; j < k; j++) {
if (x == n - 1) {
found = true;
break;
}
x = mod_mult(x, x, n);
}
if (found)
continue;
return false;
}
return true;
}
ll pollard_rho(ll n, int c) {
ll x = 2;
ll y = 2;
ll d = 1;
while (d == 1) {
x = mod_mult(x, x, n) + c;
y = mod_mult(y, y, n) + c;
y = mod_mult(y, y, n) + c;
d = __gcd((x - y >= 0 ? x - y : y - x), n);
}
if (d == n)
return pollard_rho(n, c + 1);
return d;
}
};
int dp[100009];
ll mod = 1e9 + 7; // 1e9+9
ll add(ll x, ll y) { return (x + y) % mod; }
ll mul(ll x, ll y) { return (x * y) % mod; }
ll mpow(ll x, ll y) {
ll v = 1;
for (; y; x = mul(x, x), y >>= 1)
if (y & 1)
v = mul(v, x);
return v;
}
ll ncr[5000][5000];
ll nCr(ll n, ll r) {
if (n == r)
return 1;
if (r == 0)
return 1;
if (ncr[n][r])
return ncr[n][r];
ncr[n][r] = (nCr(n - 1, r - 1) + nCr(n - 1, r)) % mod;
return ncr[n][r];
}
ll nHr(ll n, ll r) { return nCr(n + r - 1, n); }
int funk(ll n, ll k) {
return nHr(n, k);
return 0;
}
signed main() {
NT N(1000000007);
int n, m;
cin >> n >> m;
vector<int> v = N.mrime_decommosition(m);
map<int, int> M;
set<int> st;
r(i, v.size()) { M[v[i]]++; }
vector<int> s;
r(i, v.size()) {
if (st.count(v[i]))
continue;
st.insert(v[i]);
s.push_back(M[v[i]]);
}
int ans = 1;
r(i, s.size()) {
ans *= funk(n, s[i]);
ans %= mod;
}
cout << ans << endl;
} | #include <bits/stdc++.h>
#define r(i, n) for (int i = 0; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> P2;
#define fi first
#define se second
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
typedef long long ll;
struct NT {
ll m; // mod
vector<bool> ismrime;
vector<ll> euler;
vector<ll> fact;
NT(ll MOD) {
m = MOD;
fact.resize(500005);
fact[0] = 1;
for (ll i = 1; i < 500005; i++) {
fact[i] = (fact[i - 1] * i) % MOD;
}
}
void eratos(int n) {
ismrime.resize(n + 1);
for (int i = 0; i <= n; i++)
ismrime[i] = true;
ismrime[0] = 0;
ismrime[1] = 0;
for (int i = 2; i <= n; i++) {
if (ismrime[i]) {
for (int j = i + i; j <= n; j += i)
ismrime[j] = false;
}
}
}
// 因数分解 √N
vector<int> mrime_decommosition(ll x) {
vector<int> res;
for (int i = 2; i * i <= x; i++) {
while (x % i == 0) {
x /= i;
res.push_back(i);
}
}
if (x != 1)
res.push_back(x);
return res;
}
// 約数列挙 √N
vector<ll> divisor(ll x) {
vector<ll> res;
for (ll i = 1; i * i <= x; i++)
if (x % i == 0) {
res.push_back(i);
if (i * i != x)
res.push_back(x / i);
}
sort(res.begin(), res.end());
return res;
}
// a*b>LONG_MAX ?
bool overflow(ll a, ll b, ll LONGMAX) { return a > LONGMAX / b; }
ll extgcd(ll a, ll b, ll &x, ll &y) {
ll d = a;
if (b != 0) {
d = extgcd(b, a % b, y, x);
y -= (a / b) * x;
} else {
x = 1;
y = 0;
}
return d;
}
ll mod_inverse(ll a) {
ll x, y;
extgcd(a, m, x, y);
return (m + x % m) % m;
}
// オイラー関数√N
ll euler_mhi(ll n) {
ll res = n;
for (ll i = 2; i * i <= n; i++) {
if (n % i == 0) {
res = res / i * (i - 1);
for (; n % i == 0; n /= i)
;
}
}
if (n != 1)
res = res / n * (n - 1);
return res;
}
void make_euler_table(int n) {
euler.resize(n + 1);
for (int i = 0; i < n; i++)
euler[i] = i;
for (int i = 2; i < n; i++) {
if (euler[i] == i) {
for (int j = i; j < n; j += i) {
euler[j] = euler[j] / i * (i - 1);
}
}
}
}
// n! と nCr
// mはmod
ll mod_fact(ll n, ll &e) {
e = 0;
if (n == 0)
return 1;
int res = mod_fact(n / m, e);
e += n / m;
if (n / m % 2 != 0)
return res * (m - fact[n % m]) % m;
return res * fact[n % m] % m;
}
ll combination(ll n, ll k) {
if (n == k || k == 0)
return 1;
if (n < 0 || k < 0 || n < k)
return 0;
ll e1, e2, e3;
ll a1 = mod_fact(n, e1);
ll a2 = mod_fact(k, e2);
ll a3 = mod_fact(n - k, e3);
return a1 * mod_inverse(a2 * a3 % m) % m;
}
ll stupid_combination(ll n, ll k) {
if (n == k || k == 0)
return 1;
if (n < 0 || k < 0 || n < k)
return 0;
ll res = 1;
for (ll i = 0; i < k; i++) {
res *= (n - i);
res %= m;
res *= mod_inverse(i + 1);
res %= m;
}
return res;
}
ll mod_mult(ll a, ll b, ll m) {
ll res = 0;
ll exm = a % m;
while (b) {
if (b & 1) {
res += exm;
if (res > m)
res -= m;
}
exm <<= 1;
if (exm > m)
exm -= m;
b >>= 1;
}
return res;
}
ll mod_exm(ll a, ll b, ll m) {
ll res = 1;
ll exm = a % m;
while (b) {
if (b & 1)
res = mod_mult(res, exm, m);
exm = mod_mult(exm, exm, m);
b >>= 1;
}
return res;
}
// 確率的高速素数判定
bool miller_rabin(ll n, ll times = 10) {
if (n < 2)
return false;
if (n == 2)
return true;
if (!(n & 1))
return false;
ll q = n - 1;
int k = 0;
while (q % 2 == 0) {
k++;
q >>= 1;
}
for (int i = 0; i < times; i++) {
ll a = rand() % (n - 1) + 1;
ll x = mod_exm(a, q, n);
if (x == 1)
continue;
bool found = false;
for (int j = 0; j < k; j++) {
if (x == n - 1) {
found = true;
break;
}
x = mod_mult(x, x, n);
}
if (found)
continue;
return false;
}
return true;
}
ll pollard_rho(ll n, int c) {
ll x = 2;
ll y = 2;
ll d = 1;
while (d == 1) {
x = mod_mult(x, x, n) + c;
y = mod_mult(y, y, n) + c;
y = mod_mult(y, y, n) + c;
d = __gcd((x - y >= 0 ? x - y : y - x), n);
}
if (d == n)
return pollard_rho(n, c + 1);
return d;
}
};
int dp[100009];
ll mod = 1e9 + 7; // 1e9+9
ll add(ll x, ll y) { return (x + y) % mod; }
ll mul(ll x, ll y) { return (x * y) % mod; }
ll mpow(ll x, ll y) {
ll v = 1;
for (; y; x = mul(x, x), y >>= 1)
if (y & 1)
v = mul(v, x);
return v;
}
ll ncr[5000][5000];
ll nCr(ll n, ll r) {
if (n == r)
return 1;
if (r == 0)
return 1;
if (ncr[n][r])
return ncr[n][r];
ncr[n][r] = (nCr(n - 1, r - 1) + nCr(n - 1, r)) % mod;
return ncr[n][r];
}
ll nHr(ll n, ll r) { return nCr(n + r - 1, n); }
int funk(ll n, ll k) {
return nHr(n, k);
return 0;
}
signed main() {
NT N(1000000007);
int n, m;
cin >> n >> m;
vector<int> v = N.mrime_decommosition(m);
map<int, int> M;
set<int> st;
r(i, v.size()) { M[v[i]]++; }
vector<int> s;
r(i, v.size()) {
if (st.count(v[i]))
continue;
st.insert(v[i]);
s.push_back(M[v[i]]);
}
int ans = 1;
r(i, s.size()) {
ans *= N.combination(n + s[i] - 1, s[i]);
ans %= mod;
}
cout << ans << endl;
} | replace | 292 | 293 | 292 | 293 | -11 | |
p03253 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template <typename T> void out(T x) {
cout << x << endl;
exit(0);
}
#define watch(x) cout << (#x) << " is " << (x) << endl
const int maxn = 1e6 + 5;
const ll mod = 1e9 + 7;
ll fac[maxn], ifac[maxn];
ll modpow(ll, ll);
ll inv(ll);
ll nck(ll, ll);
void build();
void testlib();
ll n, m;
ll dp[50][50]; // # way to choose i factors to make v[j]
bool used[50][maxn];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
build();
cin >> n >> m;
vector<ll> v;
for (ll i = 1; i * i <= m; i++) {
if (m % i)
continue;
v.push_back(i);
v.push_back(m / i);
}
sort(v.begin(), v.end());
v.erase(unique(v.begin(), v.end()), v.end());
for (int i = 0; i < int(v.size()); i++) {
for (int j = 0; j < int(v.size()); j++) {
if (j > i && v[j] % v[i] == 0) {
used[i][j] = true;
}
}
}
dp[0][0] = 1;
for (int i = 0; i < 33; i++) {
for (int j = 0; j < int(v.size()); j++) {
for (int k = 0; k < int(v.size()); k++) {
if (used[j][k]) {
dp[i + 1][k] += dp[i][j];
dp[i + 1][k] %= mod;
}
}
}
}
// for (int i=0; i<5; i++) {
// for (int j=0; j<int(v.size()); j++) {
// cout<<dp[i][j]<<" ";
// }
// cout<<endl;
// }
ll ans = 0;
for (int i = 0; i < 33; i++) {
ll cur = nck(n, i) * dp[i][int(v.size()) - 1];
cur %= mod;
ans += cur;
ans %= mod;
}
cout << ans << endl;
return 0;
}
///////////////////////////////////////////////////////////////////////////////////////////////////
ll modpow(ll x, ll y) {
x %= mod;
ll res = 1;
while (y > 0) {
if (y % 2 == 1) {
res *= x;
res %= mod;
}
x = x * x;
x %= mod;
y = y / 2;
}
return res;
}
ll inv(ll x) {
assert(x != 0);
return modpow(x, mod - 2);
}
void build() {
fac[0] = ifac[0] = 1;
for (int i = 1; i < maxn; i++) {
fac[i] = fac[i - 1] * i;
fac[i] %= mod;
ifac[i] = inv(fac[i]);
ifac[i] %= mod;
}
}
ll nck(ll n, ll k) {
assert(n >= 0 && k >= 0);
if (k > n)
return 0;
return (((fac[n] * ifac[k]) % mod) * ifac[n - k]) % mod;
}
void testlib() {
assert(modpow(1, 1) == 1);
assert(modpow(4, 2) == 16);
assert(modpow(2, 5) == 32);
assert(fac[3] == 6);
assert(nck(4, 2) == 6);
assert(nck(10, 2) == 45);
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template <typename T> void out(T x) {
cout << x << endl;
exit(0);
}
#define watch(x) cout << (#x) << " is " << (x) << endl
const int maxn = 1e6 + 5;
const ll mod = 1e9 + 7;
ll fac[maxn], ifac[maxn];
ll modpow(ll, ll);
ll inv(ll);
ll nck(ll, ll);
void build();
void testlib();
ll n, m;
ll dp[50][maxn]; // # way to choose i factors to make v[j]
bool used[3009][3009];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
build();
cin >> n >> m;
vector<ll> v;
for (ll i = 1; i * i <= m; i++) {
if (m % i)
continue;
v.push_back(i);
v.push_back(m / i);
}
sort(v.begin(), v.end());
v.erase(unique(v.begin(), v.end()), v.end());
for (int i = 0; i < int(v.size()); i++) {
for (int j = 0; j < int(v.size()); j++) {
if (j > i && v[j] % v[i] == 0) {
used[i][j] = true;
}
}
}
dp[0][0] = 1;
for (int i = 0; i < 33; i++) {
for (int j = 0; j < int(v.size()); j++) {
for (int k = 0; k < int(v.size()); k++) {
if (used[j][k]) {
dp[i + 1][k] += dp[i][j];
dp[i + 1][k] %= mod;
}
}
}
}
// for (int i=0; i<5; i++) {
// for (int j=0; j<int(v.size()); j++) {
// cout<<dp[i][j]<<" ";
// }
// cout<<endl;
// }
ll ans = 0;
for (int i = 0; i < 33; i++) {
ll cur = nck(n, i) * dp[i][int(v.size()) - 1];
cur %= mod;
ans += cur;
ans %= mod;
}
cout << ans << endl;
return 0;
}
///////////////////////////////////////////////////////////////////////////////////////////////////
ll modpow(ll x, ll y) {
x %= mod;
ll res = 1;
while (y > 0) {
if (y % 2 == 1) {
res *= x;
res %= mod;
}
x = x * x;
x %= mod;
y = y / 2;
}
return res;
}
ll inv(ll x) {
assert(x != 0);
return modpow(x, mod - 2);
}
void build() {
fac[0] = ifac[0] = 1;
for (int i = 1; i < maxn; i++) {
fac[i] = fac[i - 1] * i;
fac[i] %= mod;
ifac[i] = inv(fac[i]);
ifac[i] %= mod;
}
}
ll nck(ll n, ll k) {
assert(n >= 0 && k >= 0);
if (k > n)
return 0;
return (((fac[n] * ifac[k]) % mod) * ifac[n - k]) % mod;
}
void testlib() {
assert(modpow(1, 1) == 1);
assert(modpow(4, 2) == 16);
assert(modpow(2, 5) == 32);
assert(fac[3] == 6);
assert(nck(4, 2) == 6);
assert(nck(10, 2) == 45);
}
| replace | 23 | 25 | 23 | 25 | 0 | |
p03253 | C++ | Runtime Error | #include <cstdio>
const int MOD = static_cast<int>(1e9 + 7);
const int MAXARRAY = 10;
const long long MULTILIMIT = MOD;
int Combination(int n, int k) {
int i, j, index = 1;
long long comb[MAXARRAY] = {1};
for (i = 0; i < k; i++) {
for (j = 0; j < index; j++)
comb[j] *= n - i;
for (j = 0; j < index; j++)
if (comb[j] >= MULTILIMIT) {
comb[j + 1] += comb[j] / MOD;
comb[j] %= MOD;
}
if (comb[j])
index++;
}
for (i = 2; i <= k; i++) {
for (j = index - 1; j > 0; j--) {
comb[j - 1] += (comb[j] % i) * MOD;
comb[j] /= i;
}
comb[j] /= i;
}
return static_cast<int>(comb[0] % MOD);
}
int main() {
int N, M, i, j, comb, count = 0, factor = 3, factnum[30] = {0};
long long ans = 1;
std::scanf("%d%d", &N, &M);
while (!(M & 1))
count++, M >>= 1;
factnum[count]++;
while (M != 1) {
count = 0;
while (!(M % factor))
count++, M /= factor;
factnum[count]++, factor += 2;
}
for (i = 1; i < 30; i++) {
if (factnum[i]) {
comb = Combination(i + N - 1, i);
for (j = 0; j < factnum[i]; j++) {
ans *= comb;
ans %= MOD;
}
}
}
std::printf("%d\n", static_cast<int>(ans));
return 0;
} | #include <cstdio>
const int MOD = static_cast<int>(1e9 + 7);
const int MAXARRAY = 100;
const long long MULTILIMIT = MOD;
int Combination(int n, int k) {
int i, j, index = 1;
long long comb[MAXARRAY] = {1};
for (i = 0; i < k; i++) {
for (j = 0; j < index; j++)
comb[j] *= n - i;
for (j = 0; j < index; j++)
if (comb[j] >= MULTILIMIT) {
comb[j + 1] += comb[j] / MOD;
comb[j] %= MOD;
}
if (comb[j])
index++;
}
for (i = 2; i <= k; i++) {
for (j = index - 1; j > 0; j--) {
comb[j - 1] += (comb[j] % i) * MOD;
comb[j] /= i;
}
comb[j] /= i;
}
return static_cast<int>(comb[0] % MOD);
}
int main() {
int N, M, i, j, comb, count = 0, factor = 3, factnum[30] = {0};
long long ans = 1;
std::scanf("%d%d", &N, &M);
while (!(M & 1))
count++, M >>= 1;
factnum[count]++;
while (M != 1) {
count = 0;
while (!(M % factor))
count++, M /= factor;
factnum[count]++, factor += 2;
}
for (i = 1; i < 30; i++) {
if (factnum[i]) {
comb = Combination(i + N - 1, i);
for (j = 0; j < factnum[i]; j++) {
ans *= comb;
ans %= MOD;
}
}
}
std::printf("%d\n", static_cast<int>(ans));
return 0;
} | replace | 3 | 4 | 3 | 4 | 0 | |
p03253 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout << #x " = " << ((x)) << endl
template <class T, class U>
ostream &operator<<(ostream &o, const pair<T, U> &p) {
o << "(" << p.fi << "," << p.se << ")";
return o;
}
template <class T> ostream &operator<<(ostream &o, const vector<T> &v) {
o << "[";
for (T t : v) {
o << t << ",";
}
o << "]";
return o;
}
vector<int> divisor(int x) {
vector<int> ret;
for (int i = 1; i * i <= x; ++i) {
if (x % i == 0) {
ret.pb(i);
if (x / i != i)
ret.pb(x / i);
}
}
sort(all(ret), greater<int>());
return ret;
}
const ll mod = 1e9 + 7;
ll mod_pow(ll x, ll n) {
ll ret = 1;
while (n) {
if (n & 1)
(ret *= x) %= mod;
(x *= x) %= mod;
n >>= 1;
}
return ret;
}
ll mod_inv(ll x) { return mod_pow(x, mod - 2); }
const int F = 100010;
ll f[F];
ll C(int n, int r) {
ll ret = f[n];
(ret *= mod_inv(f[r])) %= mod;
(ret *= mod_inv(f[n - r])) %= mod;
return ret;
}
int n, m;
vector<int> d;
int D;
const int MD = 334;
const int N = 50;
map<ll, ll> dp[MD][N];
ll dfs(int dep, int cr_n, int re_m) {
// printf(" CALL(%d %d %d) \n", dep,cr_n,re_m);
if (dep == D - 1)
return re_m == 1;
if (dp[dep][cr_n].count(re_m))
return dp[dep][cr_n][re_m];
ll ret = 0;
int tmp = re_m;
int i = 0;
while (1) {
if (cr_n + i > n)
break;
// printf(" d[dep] %d , i %d\n",d[dep],i);
ret += (dfs(dep + 1, cr_n + i, tmp) * C(n - cr_n, i)) % mod;
ret %= mod;
if (tmp % d[dep] != 0)
break;
tmp /= d[dep];
++i;
}
// printf(" (%d %d %d) %lld\n", dep,cr_n,re_m,ret);
dp[dep][cr_n][re_m] = ret;
return ret;
}
int main() {
f[0] = 1;
for (int i = 1; i < F; ++i)
f[i] = (f[i - 1] * i) % mod;
cin >> n >> m;
d = divisor(m);
D = d.size();
cout << dfs(0, 0, m) << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout << #x " = " << ((x)) << endl
template <class T, class U>
ostream &operator<<(ostream &o, const pair<T, U> &p) {
o << "(" << p.fi << "," << p.se << ")";
return o;
}
template <class T> ostream &operator<<(ostream &o, const vector<T> &v) {
o << "[";
for (T t : v) {
o << t << ",";
}
o << "]";
return o;
}
vector<int> divisor(int x) {
vector<int> ret;
for (int i = 1; i * i <= x; ++i) {
if (x % i == 0) {
ret.pb(i);
if (x / i != i)
ret.pb(x / i);
}
}
sort(all(ret), greater<int>());
return ret;
}
const ll mod = 1e9 + 7;
ll mod_pow(ll x, ll n) {
ll ret = 1;
while (n) {
if (n & 1)
(ret *= x) %= mod;
(x *= x) %= mod;
n >>= 1;
}
return ret;
}
ll mod_inv(ll x) { return mod_pow(x, mod - 2); }
const int F = 100010;
ll f[F];
ll C(int n, int r) {
ll ret = f[n];
(ret *= mod_inv(f[r])) %= mod;
(ret *= mod_inv(f[n - r])) %= mod;
return ret;
}
int n, m;
vector<int> d;
int D;
const int MD = 1000;
const int N = 50;
map<ll, ll> dp[MD][N];
ll dfs(int dep, int cr_n, int re_m) {
// printf(" CALL(%d %d %d) \n", dep,cr_n,re_m);
if (dep == D - 1)
return re_m == 1;
if (dp[dep][cr_n].count(re_m))
return dp[dep][cr_n][re_m];
ll ret = 0;
int tmp = re_m;
int i = 0;
while (1) {
if (cr_n + i > n)
break;
// printf(" d[dep] %d , i %d\n",d[dep],i);
ret += (dfs(dep + 1, cr_n + i, tmp) * C(n - cr_n, i)) % mod;
ret %= mod;
if (tmp % d[dep] != 0)
break;
tmp /= d[dep];
++i;
}
// printf(" (%d %d %d) %lld\n", dep,cr_n,re_m,ret);
dp[dep][cr_n][re_m] = ret;
return ret;
}
int main() {
f[0] = 1;
for (int i = 1; i < F; ++i)
f[i] = (f[i - 1] * i) % mod;
cin >> n >> m;
d = divisor(m);
D = d.size();
cout << dfs(0, 0, m) << endl;
return 0;
}
| replace | 65 | 66 | 65 | 66 | 0 | |
p03253 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
using Int = long long;
// BEGIN CUT HERE
template <typename T, T MOD = 1000000007> struct Mint {
T v;
Mint() : v(0) {}
Mint(signed v) : v(v) {}
Mint(long long t) {
v = t % MOD;
if (v < 0)
v += MOD;
}
Mint pow(int k) {
Mint res(1), tmp(v);
while (k) {
if (k & 1)
res *= tmp;
tmp *= tmp;
k >>= 1;
}
return res;
}
Mint inv() { return pow(MOD - 2); }
Mint &operator+=(Mint a) {
v += a.v;
if (v >= MOD)
v -= MOD;
return *this;
}
Mint &operator-=(Mint a) {
v += MOD - a.v;
if (v >= MOD)
v -= MOD;
return *this;
}
Mint &operator*=(Mint a) {
v = 1LL * v * a.v % MOD;
return *this;
}
Mint &operator/=(Mint a) { return (*this) *= a.inv(); }
Mint operator+(Mint a) { return Mint(v) += a; };
Mint operator-(Mint a) { return Mint(v) -= a; };
Mint operator*(Mint a) { return Mint(v) *= a; };
Mint operator/(Mint a) { return Mint(v) /= a; };
Mint operator-() { return v ? MOD - v : v; }
bool operator==(const Mint a) const { return v == a.v; }
bool operator!=(const Mint a) const { return v != a.v; }
static vector<Mint> fact, finv, invs;
void init(int n) {
if (n + 1 <= (signed)fact.size())
return;
fact.assign(n + 1, 1);
finv.assign(n + 1, 1);
invs.assign(n + 1, 1);
for (int i = 1; i <= n; i++)
fact[i] = fact[i - 1] * Mint(i);
finv[n] = Mint(1) / fact[n];
for (int i = n; i >= 1; i--)
finv[i - 1] = finv[i] * Mint(i);
for (int i = 1; i <= n; i++)
invs[i] = finv[i] * fact[i - 1];
}
Mint comb(long long n, int k) {
Mint res(1);
for (int i = 0; i < k; i++) {
res *= Mint(n - i);
res /= Mint(i + 1);
}
return res;
}
Mint C(int n, int k) {
if (n < k || k < 0)
return Mint(0);
return fact[n] * finv[n - k] * finv[k];
}
Mint P(int n, int k) {
if (n < k || k < 0)
return Mint(0);
return fact[n] * finv[n - k];
}
Mint H(int n, int k) {
if (n < 0 || k < 0)
return Mint(0);
if (!n && !k)
return Mint(1);
return C(n + k - 1, n);
}
Mint S(int n, int k) {
Mint res;
for (int i = 1; i <= k; i++) {
Mint tmp = C(k, i) * Mint(i).pow(n);
if ((k - i) & 1)
res -= tmp;
else
res += tmp;
}
return res *= finv[k];
}
Mint B(int n, int k) {
Mint res;
for (int j = 1; j <= k; j++)
res += S(n, j);
return res;
}
Mint montmort(int n) {
Mint res;
for (int k = 2; k <= n; k++) {
if (k & 1)
res -= finv[k];
else
res += finv[k];
}
return res *= fact[n];
}
};
template <typename T, T MOD>
vector<Mint<T, MOD>> Mint<T, MOD>::fact = vector<Mint<T, MOD>>();
template <typename T, T MOD>
vector<Mint<T, MOD>> Mint<T, MOD>::finv = vector<Mint<T, MOD>>();
template <typename T, T MOD>
vector<Mint<T, MOD>> Mint<T, MOD>::invs = vector<Mint<T, MOD>>();
// END CUT HERE
template <typename T> map<T, int> factorize(T x) {
map<T, int> res;
for (int i = 2; i * i <= x; i++) {
while (x % i == 0) {
x /= i;
res[i]++;
}
}
if (x != 1)
res[x]++;
return res;
}
// INSERT ABOVE HERE
signed ABC110_D() {
int n;
Mint<int> m;
scanf("%d %d", &n, &m.v);
m.init(n + 100);
Mint<int> ans(1);
auto x = factorize(m.v);
for (auto p : x)
ans *= m.H(p.second, n);
printf("%d\n", ans.v);
return 0;
}
/*
verified on 2018/09/24
https://beta.atcoder.jp/contests/abc110/tasks/abc110_d
*/
// montmort
signed ARC009_C() {
Int n, k;
scanf("%lld %lld", &n, &k);
const int MMOD = 1777777777;
using MM = Mint<long long, MMOD>;
MM m;
m.init(k + 1);
MM a = m.montmort(k);
a *= m.comb(n, k);
printf("%lld\n", a.v);
return 0;
}
/*
verified on 2018/09/24
https://beta.atcoder.jp/contests/arc009/tasks/arc009_3
*/
signed main() {
// ABC110_D();
ARC009_C();
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
using Int = long long;
// BEGIN CUT HERE
template <typename T, T MOD = 1000000007> struct Mint {
T v;
Mint() : v(0) {}
Mint(signed v) : v(v) {}
Mint(long long t) {
v = t % MOD;
if (v < 0)
v += MOD;
}
Mint pow(int k) {
Mint res(1), tmp(v);
while (k) {
if (k & 1)
res *= tmp;
tmp *= tmp;
k >>= 1;
}
return res;
}
Mint inv() { return pow(MOD - 2); }
Mint &operator+=(Mint a) {
v += a.v;
if (v >= MOD)
v -= MOD;
return *this;
}
Mint &operator-=(Mint a) {
v += MOD - a.v;
if (v >= MOD)
v -= MOD;
return *this;
}
Mint &operator*=(Mint a) {
v = 1LL * v * a.v % MOD;
return *this;
}
Mint &operator/=(Mint a) { return (*this) *= a.inv(); }
Mint operator+(Mint a) { return Mint(v) += a; };
Mint operator-(Mint a) { return Mint(v) -= a; };
Mint operator*(Mint a) { return Mint(v) *= a; };
Mint operator/(Mint a) { return Mint(v) /= a; };
Mint operator-() { return v ? MOD - v : v; }
bool operator==(const Mint a) const { return v == a.v; }
bool operator!=(const Mint a) const { return v != a.v; }
static vector<Mint> fact, finv, invs;
void init(int n) {
if (n + 1 <= (signed)fact.size())
return;
fact.assign(n + 1, 1);
finv.assign(n + 1, 1);
invs.assign(n + 1, 1);
for (int i = 1; i <= n; i++)
fact[i] = fact[i - 1] * Mint(i);
finv[n] = Mint(1) / fact[n];
for (int i = n; i >= 1; i--)
finv[i - 1] = finv[i] * Mint(i);
for (int i = 1; i <= n; i++)
invs[i] = finv[i] * fact[i - 1];
}
Mint comb(long long n, int k) {
Mint res(1);
for (int i = 0; i < k; i++) {
res *= Mint(n - i);
res /= Mint(i + 1);
}
return res;
}
Mint C(int n, int k) {
if (n < k || k < 0)
return Mint(0);
return fact[n] * finv[n - k] * finv[k];
}
Mint P(int n, int k) {
if (n < k || k < 0)
return Mint(0);
return fact[n] * finv[n - k];
}
Mint H(int n, int k) {
if (n < 0 || k < 0)
return Mint(0);
if (!n && !k)
return Mint(1);
return C(n + k - 1, n);
}
Mint S(int n, int k) {
Mint res;
for (int i = 1; i <= k; i++) {
Mint tmp = C(k, i) * Mint(i).pow(n);
if ((k - i) & 1)
res -= tmp;
else
res += tmp;
}
return res *= finv[k];
}
Mint B(int n, int k) {
Mint res;
for (int j = 1; j <= k; j++)
res += S(n, j);
return res;
}
Mint montmort(int n) {
Mint res;
for (int k = 2; k <= n; k++) {
if (k & 1)
res -= finv[k];
else
res += finv[k];
}
return res *= fact[n];
}
};
template <typename T, T MOD>
vector<Mint<T, MOD>> Mint<T, MOD>::fact = vector<Mint<T, MOD>>();
template <typename T, T MOD>
vector<Mint<T, MOD>> Mint<T, MOD>::finv = vector<Mint<T, MOD>>();
template <typename T, T MOD>
vector<Mint<T, MOD>> Mint<T, MOD>::invs = vector<Mint<T, MOD>>();
// END CUT HERE
template <typename T> map<T, int> factorize(T x) {
map<T, int> res;
for (int i = 2; i * i <= x; i++) {
while (x % i == 0) {
x /= i;
res[i]++;
}
}
if (x != 1)
res[x]++;
return res;
}
// INSERT ABOVE HERE
signed ABC110_D() {
int n;
Mint<int> m;
scanf("%d %d", &n, &m.v);
m.init(n + 100);
Mint<int> ans(1);
auto x = factorize(m.v);
for (auto p : x)
ans *= m.H(p.second, n);
printf("%d\n", ans.v);
return 0;
}
/*
verified on 2018/09/24
https://beta.atcoder.jp/contests/abc110/tasks/abc110_d
*/
// montmort
signed ARC009_C() {
Int n, k;
scanf("%lld %lld", &n, &k);
const int MMOD = 1777777777;
using MM = Mint<long long, MMOD>;
MM m;
m.init(k + 1);
MM a = m.montmort(k);
a *= m.comb(n, k);
printf("%lld\n", a.v);
return 0;
}
/*
verified on 2018/09/24
https://beta.atcoder.jp/contests/arc009/tasks/arc009_3
*/
signed main() {
ABC110_D();
// ARC009_C();
return 0;
}
| replace | 193 | 195 | 193 | 195 | 0 |
Subsets and Splits