#include <windows.h>#include <stdio.h>#include <unordered_map>#include <algorithm>#include <iostream>#include <cstring>#include <cstdio>#include <vector>#include <bitset>#include <cmath>#include <queue>#include <ctime>#include <set>#include <map>#define int long long#define rep(i, a, b) for (int i = (a); i <= (b); i ++ )
#define rop(i, a, b) for (int i = (a); i < (b); i ++ )
#define dep(i, a, b) for (int i = (a); i >= (b); i -- )
#define dop(i, a, b) for (int i = (a); i > (b); i -- )
#define Darr(a, L, R) (cerr << #a "[" << L << " ~ " << R << "] = "; rep(x, L, R) cerr << a[x] << " "; cerr << '\n';)
#define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define D(x) (cerr << #x << " = " << x << '\n')
#define vit vector<int>::iterator
#define all(x) x.begin(), x.end()
#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)
#define chkmin(a, b) (a = min(a, b))
#define chkmax(a, b) (a = max(a, b))
#define clr(x) (memset(x, 0, sizeof x))
#define mid (tr[u].l + tr[u].r >> 1)
#define sit set<int>::iterator
#define lowbit(x) (x & -x)
#define rs (u << 1 | 1)
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define ls (u << 1)
#define pi acos(-1)
#define gc getchar
#define pc putchar
#define db double#define y second
#define x first
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef pair<db, db> PDD;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
const int mod = 998244353;
const int eps = 1e-9;
int T = 1;
void print(int x) { dep(i, 20, 0) pc(((x >> i) & 1) ? '1' : '0'); }
int qpow(int a, int b = mod - 2) {
int ans = 1; for (; b; b >>= 1, a = 1ll * a * a % mod)
if (b & 1) ans = 1ll * ans * a % mod; return ans;
}
int mul(int a, int b) {
int ans = 0; for (; b; b >>= 1, a = (LL)(a + a) % mod)
if (b & 1) ans = (LL)(ans + a) % mod; return ans;
}
void getline(char *s) {
char ch = gc(); char *beg = s;
for (; ch != '\n' && ch != '\r'; (*beg ++ ) = ch, ch = getchar());
}
void read() { return; }
template <typename T, typename ...T2>
void read(T &s, T2 &...oth) {
s = 0; char ch = gc(); bool f = 0;
for (; ch < '0' or ch > '9'; ch = gc()) if (ch == '-') f = 1;
for (; ch >= '0' and ch <= '9'; ch = gc()) s = (s << 1) + (s << 3) + (ch ^ 48);
s = f ? -s : s; read(oth...); return;
}
void write(char ch) { return; }
template <typename T, typename ...T2>
void write(char ch, T s, T2 ...oth) {
if (!s) { pc('0'); pc(ch); write(ch, oth...); return; }
int stk[100], top = 0;
if (s < 0) pc('-'), s = ~s + 1;
while (s) stk[ ++ top] = s % 10, s /= 10;
do pc(stk[top -- ] + (1 << 4) + (1 << 5)); while (top);
pc(ch); write(ch, oth...); return;
}
void COLOR_PRINT(const char* s, int color) {
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | color);
printf(s);
SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | 7);
}
void sub() {
puts("Input Your Program : ");
string In; cin >> In;
puts("Input Standard example : ");
string k; cin >> k;
puts("Input examples : ");
int n; cin >> n;
rep(i, 1, n) {
double st = clock();
string t = k + to_string(i) + ".in";
string a = In + ".exe < " + t + " > tmp.out";
string b = "fc tmp.out " + k + to_string(i) + ".ans > 1.log";
system(a.c_str());
if (!system(b.c_str()))
COLOR_PRINT("Test Passed!\n", 2);
else COLOR_PRINT("Test Failed!\n", 4);
double ed = clock();
printf("Time Use : %.5lf\n", (double)(ed - st) / CLOCKS_PER_SEC);
}
}
signed main() {
// read(T);while (T -- ) sub();
return 0;
}
modint 2.0 版
C++
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#include <unordered_map>#include <algorithm>#include <iostream>#include <cstring>#include <cstdio>#include <vector>#include <bitset>#include <cmath>#include <queue>#include <ctime>#include <set>#include <map>#define int long long#define rep(i, a, b) for (int i = (a); i <= (b); i ++ )
#define rop(i, a, b) for (int i = (a); i < (b); i ++ )
#define dep(i, a, b) for (int i = (a); i >= (b); i -- )
#define dop(i, a, b) for (int i = (a); i > (b); i -- )
#define Darr(a, L, R) (cerr << #a "[" << L << " ~ " << R << "] = "; rep(x, L, R) cerr << a[x] << " "; cerr << '\n';)
#define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define D(x) (cerr << #x << " = " << x << '\n')
#define vit vector<int>::iterator
#define all(x) x.begin(), x.end()
#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)
#define chkmin(a, b) (a = min(a, b))
#define chkmax(a, b) (a = max(a, b))
#define clr(x) (memset(x, 0, sizeof x))
#define mid (tr[u].l + tr[u].r >> 1)
#define sit set<int>::iterator
#define lowbit(x) (x & -x)
#define rs (u << 1 | 1)
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define ls (u << 1)
#define pi acos(-1)
#define gc getchar
#define pc putchar
#define db double#define y second
#define x first
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef pair<db, db> PDD;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
const int mod = 998244353;
const int eps = 1e-9;
int T = 1;
void print(int x) { dep(i, 20, 0) pc(((x >> i) & 1) ? '1' : '0'); }
int qpow(int a, int b = mod - 2) {
int ans = 1; for (; b; b >>= 1, a = 1ll * a * a % mod)
if (b & 1) ans = 1ll * ans * a % mod; return ans;
}
int mul(int a, int b) {
int ans = 0; for (; b; b >>= 1, a = (LL)(a + a) % mod)
if (b & 1) ans = (LL)(ans + a) % mod; return ans;
}
void getline(char *s) {
char ch = gc(); char *beg = s;
for (; ch != '\n' && ch != '\r'; (*beg ++ ) = ch, ch = getchar());
}
namespace simpler {
template <const unsigned _Mod = INT32_MAX>
class modint {
protected :int64_t _val;
typedef modint<_Mod> _mint;
friend inline _mint
__construct(_mint && _res, int64_t _x) { _res._val = _x; return _res; }
template<class _Tp> friend _mint
__quickly_power(_mint _a, _Tp _b) {
if (_b <= 0) return 1; _mint _res = 1;
for(; (bool)_b; _b >>= 1, _a *= _a) if(_b & 1) _res *= _a;
return _res;
}
template<class _Tp> friend _mint
__inv(_mint t) { return __quickly_power(t.val); }
public :modint() : _val(0){}
template<class _Tp>modint(_Tp _x) { _val = ((int64_t)_x % _Mod + _Mod) % _Mod; }
template<class _Tp> explicit inline operator _Tp() {return (_Tp)_val; }
friend _mint operator + (const _mint& _a,const _mint& _b){
if (_a._val + _b._val >= _Mod)return __construct(_mint(), _a._val + _b._val - _Mod);
return __construct(_mint(), _a._val + _b._val); }
inline _mint& operator += (const _mint& _b) { return *this = *this + _b; }
inline _mint& operator ++ () { return *this = *this + __construct(_mint(), 1); }
friend _mint operator - (const _mint& _a, const _mint& _b) {
if (_a._val - _b._val < 0) return __construct(_mint(), _a._val - _b._val + _Mod);
return __construct(_mint(), _a._val - _b._val); }
inline _mint& operator -= (const _mint& _b) { return *this = *this - _b; }
inline _mint& operator -- () { return *this = *this - __construct(_mint(), 1); }
friend inline _mint
operator * (const _mint& _a, const _mint& _b) { return __construct(_mint(), _a._val * _b._val % _Mod); }
inline _mint& operator *= (const _mint& _b){ return *this =* this * _b; }//multipliesfriend inline _mint
operator / (const _mint& _a, const _mint& _b) { return __construct(_mint(), _a.val * __inv(_b) % _Mod); }
_mint operator - () { return __construct(_mint(), _val ? _Mod - _val : _val); }//negativefriend inline _mint operator % (const _mint &_a, const int &b) { return __construct(_mint(), _a._val % b); }
friend inline _mint operator % (const _mint& _a, const _mint& _b) { return __construct(_mint(), _a._val % _b._val); }
inline _mint& operator %= (const _mint& _b) { return *this = *this % _b; }//modulusfriend inline bool operator == (const _mint& _a, const _mint& _b) { return _a._val == _b._val; }
friend inline bool operator != (const _mint& _a, const _mint& _b) { return _a._val != _b._val; }
friend inline bool operator < (const _mint& _a, const _mint& _b) { return _a._val < _b._val; }
friend inline bool operator > (const _mint& _a, const _mint& _b) { return _a._val > _b._val; }
friend inline bool operator <= (const _mint& _a, const _mint& _b) { return _a._val <= _b._val; }
friend inline bool operator >= (const _mint& _a, const _mint& _b) { return _a._val >= _b._val; }
friend inline _mint operator & (const _mint& _a, const _mint& _b) { return _a._val & _b._val; }
friend inline _mint operator | (const _mint& _a, const _mint& _b) { return _a._val | _b._val; }
friend inline _mint operator ^ (const _mint& _a,const _mint& _b) { return _a._val ^ _b._val; }
friend inline _mint operator << (const _mint& _a, const _mint& _b) { return _a._val << _b._val; }
friend inline _mint operator >> (const _mint& _a, const _mint& _b) { return _a._val >> _b._val; }
inline _mint& operator &= (const _mint& _b) {return *this = *this & _b; }
inline _mint& operator |= (const _mint& _b) {return *this = *this | _b; }
inline _mint& operator ^= (const _mint& _b) {return *this = *this ^ _b; }
inline _mint& operator <<= (const _mint& _b) {return *this = *this << _b; }
inline _mint& operator >>= (const _mint& _b) {return *this = *this >> _b; }
inline _mint operator ~ ()const { return __construct(_mint(), ~_val); }
inline bool operator !()const {return !_val; }
friend inline std::istream& operator >> (std::istream& _is, _mint& _b) { return _is >> _b._val; }
friend inline std::ostream& operator << (std::ostream& _os, const _mint& _b) { return _os << _b._val; }
template<class _Tp>_mint
power(_Tp _n) const { return __quickly_power(*this, _n); }
inline _mint inv() const { return __quickly_power(*this, _Mod - 2); }
friend inline _mint operator / (const _mint& _a, const _mint& _b) {
return __construct(_mint(), _a._val * _b.inv()._val % _Mod); }
inline _mint& operator /= (const _mint& _b) { return *this = *this / _b; }
};//modint 2.0
} using mint = simpler::modint<998244353>;
void read() { return; }
template <typename T, typename ...T2>
void read(T &s, T2 &...oth) {
s = 0; char ch = gc(); bool f = 0;
for (; ch < '0' or ch > '9'; ch = gc()) if (ch == '-') f = 1;
for (; ch >= '0' and ch <= '9'; ch = gc()) s = (s << 1) + (s << 3) + (ch ^ 48);
s = f ? -s : s; read(oth...); return;
}
void write(char ch) { return; }
template <typename T, typename ...T2>
void write(char ch, T s, T2 ...oth) {
if (!s) { pc('0'); pc(ch); write(ch, oth...); return; }
int stk[100], top = 0;
if (s < 0) pc('-'), s = ~s + 1;
while (s) stk[ ++ top] = s % 10, s /= 10;
do pc(stk[top -- ] + (1 << 4) + (1 << 5)); while (top);
pc(ch); write(ch, oth...); return;
}
void sub() {
}
signed main() {
// read(T);while (T -- ) sub();
return 0;
}
简易版
C++
#include <algorithm>#include <iostream>#include <cstring>#include <cstdio>#include <vector>#include <bitset>#include <cmath>#include <set>#include <map>#define int long long#define rep(i, a, b) for (int i = (a); i <= (b); i ++ )
#define rop(i, a, b) for (int i = (a); i < (b); i ++ )
#define dep(i, a, b) for (int i = (a); i >= (b); i -- )
#define dop(i, a, b) for (int i = (a); i > (b); i -- )
#define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define D(x) (cerr << #x << " = " << x << '\n')
#define all(x) x.begin(), x.end()
#define lowbit(x) (x & -x)
#define pb push_back
#define gc getchar
#define pc putchar
#define db double#define y second
#define x first
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
const int mod = 998244353;
void read() { return; }
template <typename T, typename ...T2>
void read(T &s, T2 &...oth) {
s = 0; char ch = gc(); bool f = 0;
for (; ch < '0' or ch > '9'; ch = gc()) if (ch == '-') f = 1;
for (; ch >= '0' and ch <= '9'; ch = gc()) s = (s << 1) + (s << 3) + (ch ^ 48);
s = f ? -s : s; read(oth...); return;
}
void write(char ch) { return; }
template <typename T, typename ...T2>
void write(char ch, T s, T2 ...oth) {
if (!s) { pc('0'); pc(ch); write(ch, oth...); return; }
int stk[100], top = 0;
if (s < 0) pc('-'), s = ~s + 1;
while (s) stk[ ++ top] = s % 10, s /= 10;
do pc(stk[top -- ] + (1 << 4) + (1 << 5)); while (top);
pc(ch); write(ch, oth...); return;
}
复杂版
C++
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#include <unordered_map>#include <algorithm>#include <iostream>#include <cstring>#include <cstdio>#include <vector>#include <bitset>#include <cmath>#include <queue>#include <set>#include <map>#define rep(i, a, b) for (int i = (a); i <= (b); i ++ )
#define rop(i, a, b) for (int i = (a); i < (b); i ++ )
#define dep(i, a, b) for (int i = (a); i >= (b); i -- )
#define dop(i, a, b) for (int i = (a); i > (b); i -- )
#define Darr(a, L, R) (cerr << #a "[" << L << " ~ " << R << "] = "; rep(x, L, R) cerr << a[x] << " "; cerr << '\n';)
#define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define D(x) (cerr << #x << " = " << x << '\n')
#define vit vector<int>::iterator
#define all(x) x.begin(), x.end()
#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)
#define chkmin(a, b) (a = min(a, b))
#define chkmax(a, b) (a = max(a, b))
#define clr(x) (memset(x, 0, sizeof x))
#define mid (tr[u].l + tr[u].r >> 1)
#define sit set<int>::iterator
#define lowbit(x) (x & -x)
#define rs (u << 1 | 1)
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define ls (u << 1)
#define pi acos(-1)
#define gc getchar
#define pc putchar
#define db double#define y second
#define x first
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef pair<db, db> PDD;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
const int mod = 998244353;
const int eps = 1e-9;
void print(int x) { dep(i, 20, 0) pc(((x >> i) & 1) ? '1' : '0'); }
int qpow(int a, int b = mod - 2) {
int ans = 1; for (; b; b >>= 1, a = 1ll * a * a % mod)
if (b & 1) ans = 1ll * ans * a % mod; return ans;
}
int mul(int a, int b) {
int ans = 0; for (; b; b >>= 1, a = (LL)(a + a) % mod)
if (b & 1) ans = (LL)(ans + a) % mod; return ans;
}
void getline(char *s) {
char ch = gc(); char *beg = s;
for (; ch != '\n' && ch != '\r'; (*beg ++ ) = ch, ch = getchar());
}
struct modint {
int x;
modint() { x = 0; }
modint(int x) : x(x) {}
int Mod(int a, int b) {
LL s = 1ll * a + 1ll * b;
return (s < 0 ? s + mod : (s >= mod? s - mod : s));
}
modint operator < (const modint &t)const { return x < t.x; }
modint operator > (const modint &t)const { return x > t.x; }
modint operator == (const modint &t)const { return x == t.x; }
modint operator + (modint &t) { modint s(Mod(x, t.x)); return s; }
modint operator - (modint &t) { modint s(Mod(x, -t.x)); return s; }
modint operator * (modint &t) { modint s(1ll * x * t.x % mod); return s; }
modint operator / (modint &t) { modint s(1ll * x * qpow(t.x) % mod); return s; }
};
void read() { return; }
template <typename T, typename ...T2>
void read(T &s, T2 &...oth) {
s = 0; char ch = gc(); bool f = 0;
for (; ch < '0' or ch > '9'; ch = gc()) if (ch == '-') f = 1;
for (; ch >= '0' and ch <= '9'; ch = gc()) s = (s << 1) + (s << 3) + (ch ^ 48);
s = f ? -s : s; read(oth...); return;
}
void write(char ch) { return; }
template <typename T, typename ...T2>
void write(char ch, T s, T2 ...oth) {
if (!s) { pc('0'); pc(ch); write(ch, oth...); return; }
int stk[100], top = 0;
if (s < 0) pc('-'), s = ~s + 1;
while (s) stk[ ++ top] = s % 10, s /= 10;
do pc(stk[top -- ] + (1 << 4) + (1 << 5)); while (top);
pc(ch); write(ch, oth...); return;
}