結果
問題 | No.1156 Nada Picnic 2 |
ユーザー | UMRgurashi |
提出日時 | 2022-07-01 23:12:43 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 4,133 bytes |
コンパイル時間 | 5,434 ms |
コンパイル使用メモリ | 266,588 KB |
実行使用メモリ | 10,752 KB |
最終ジャッジ日時 | 2024-05-04 17:41:39 |
合計ジャッジ時間 | 10,811 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | TLE | - |
testcase_02 | -- | - |
ソースコード
#include <bits/stdc++.h> #include <cstdlib> #include <atcoder/all> using namespace atcoder; #define int long long #define double long double #define stoi stoll #define endl "\n" using std::abs; using namespace std; //constexpr int MOD = 1000000007; constexpr int MOD = 998244353; using mint = modint1000000007; //using mint = modint998244353; constexpr double PI = 3.14159265358979323846; const int INF = 1LL << 62; const int dx[4] = { 1, 0, -1, 0 }; const int dy[4] = { 0, 1, 0, -1 }; #define rep(i,n) for(int i=0;i<n;++i) #define REP(i,n) for(int i=1;i<=n;i++) #define sREP(i,n) for(int i=1;i*i<=n;++i) #define krep(i,k,n) for(int i=(k);i<n+k;i++) #define Krep(i,k,n) for(int i=(k);i<n;i++) #define rrep(i,n) for(int i=n-1;i>=0;i--) #define Rrep(i,n) for(int i=n;i>0;i--) #define LAST(x) x[x.size()-1] #define ALL(x) (x).begin(),(x).end() #define MAX(x) *max_element(ALL(x)) #define MIN(x) *min_element(ALL(x) #define RUD(a,b) (((a)+(b)-1)/(b)) #define sum1_n(n) ((n)*(n+1)/2) #define SUM1n2(n) (n*(2*n+1)*(n+1))/6 #define SUMkn(k,n) (SUM1n(n)-SUM1n(k-1)) #define SZ(x) ((int)(x).size()) #define PB push_back #define Fi first #define Se second template<class... T> constexpr auto min(T... a) { return min(initializer_list<common_type_t<T...>>{a...}); } template<class... T> constexpr auto max(T... a) { return max(initializer_list<common_type_t<T...>>{a...}); } template<class... T> void in(T&... a) { (cin >> ... >> a); } template <class T> using v = vector<T>; template <class T> using vv = vector<v<T>>; template <class T> using vvv = vector<vv<T>>; using pint = pair<int, int>; double LOG(int a, int b) { return log(b) / log(a); } double DISTANCE(int x1, int y1, int x2, int y2) { return sqrt(abs(x1 - x2) * abs(x1 - x2) + abs(y1 - y2) * abs(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 BETWEEN2(int i, int j, int H, int W) { if (BETWEEN(i, 0, H - 1) && BETWEEN(j, 0, W - 1)) return true; else return false; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } inline bool bit(int x, int i) { return x >> i & 1; } int ini() { int x; cin >> x; return x; } string ins() { string x; cin >> x; return x; } void yn(bool x) { if (x) { cout << "Yes" << endl; } else { cout << "No" << endl; } } void YN(bool x) { if (x) { cout << "YES" << endl; } else { cout << "NO" << endl; } } int ipow(int x, int n) { int ans = 1; while (n > 0) { if (n & 1) ans *= x; x *= x; n >>= 1; } return ans; } template <typename T> vector<T> compress(vector<T>& X) { vector<T> vals = X; sort(ALL(vals)); vals.erase(unique(ALL(vals)), vals.end()); rep(i, SZ(X)) X[i] = lower_bound(ALL(vals), X[i]) - vals.begin(); return vals; } int f(v<int> vc) { int ans = 0; reverse(ALL(vc)); rep(i, SZ(vc))ans += ipow(i, 10)*vc[i]; return ans; } void solve() { int N = ini(); if (N == 1) { REP(si, 9)REP(i, 9)rep(ta, 10)REP(ke, 9)rep(ya, 10)rep(ma, 10)rep(ki, 10) { v<int> a = { si,i,ta }; v<int> b = { ke,ya,ma }; v<int> c = { i,ki,ta,i }; if (f(a) + f(b) == f(c)) { cout << f(c) << endl; return; } } } else if (N == 2) { REP(o, 9)rep(tu, 10)rep(ka, 10)REP(ko, 9)rep(ku, 10)rep(sa, 10)rep(i, 10)REP(bi,9)rep(zi,10)rep(nn,10) { v<int> a = { o,o,sa,ka }; v<int> b = { ko,ku,sa,i }; v<int> c = { bi,zi,tu,ka,nn }; if (f(a) + f(b) == f(c)) { cout << f(c) << endl; return; } } } else { REP(s, 9)REP(p, 9)rep(r, 10)rep(i, 10)rep(n, 10)rep(g, 10)REP(e, 9)rep(h, 10)rep(t, 10)rep(c, 10) { v<int> a = { s,p,r,i,n,g }; v<int> b = { e,i,g,h,t }; v<int> cv = { p,i,c,n,i,c }; if (f(a) + f(b) == f(cv)) { cout << f(cv) << endl; return; } } } } signed main() { //ios::sync_with_stdio(false); //cin.tie(nullptr); cout << fixed << setprecision(15); solve(); }