Submission #00004
ソースコード
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 | /* #region Head */ #include <bits/stdc++.h> using namespace std; using ll = long long ; using ull = unsigned long long ; using ld = long double ; using pll = pair<ll, ll>; template < class T> using vc = vector<T>; template < class T> using vvc = vc<vc<T>>; using vll = vc<ll>; using vvll = vvc<ll>; using vld = vc<ld>; using vvld = vvc<ld>; using vs = vc<string>; using vvs = vvc<string>; template < class T, class U> using um = unordered_map<T, U>; template < class T> using pq = priority_queue<T>; template < class T> using pqa = priority_queue<T, vc<T>, greater<T>>; template < class T> using us = unordered_set<T>; #define REP(i, m, n) for (ll i = (m), i##_len = (ll)(n); i < i##_len; ++(i)) #define REPM(i, m, n) for (ll i = (m), i##_max = (ll)(n); i <= i##_max; ++(i)) #define REPR(i, m, n) for (ll i = (m), i##_min = (ll)(n); i >= i##_min; --(i)) #define REPD(i, m, n, d) for (ll i = (m), i##_len = (ll)(n); i < i##_len; i += (d)) #define REPMD(i, m, n, d) for (ll i = (m), i##_max = (ll)(n); i <= i##_max; i += (d)) #define REPI(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++) #define ALL(x) begin(x), end(x) #define SIZE(x) ((ll)(x).size()) #define PERM(c) \ sort(ALL(c)); \ for ( bool c##p = 1; c##p; c##p = next_permutation(ALL(c))) #define UNIQ(v) v.erase(unique(ALL(v)), v.end()); #define CEIL(a, b) (((a) + (b)-1) / (b)) #define endl '\n' constexpr ll INF = 1 '010' 000 '000' 000 '000' 017LL; constexpr int IINF = 1 '000' 000'007LL; constexpr ll MOD = 1 '000' 000'007LL; // 1e9 + 7 // constexpr ll MOD = 998244353; constexpr ld EPS = 1e-12; constexpr ld PI = 3.14159265358979323846; template < typename T> istream &operator>>(istream &is, vc<T> &vec) { // vector 入力 for (T &x : vec) is >> x; return is; } template < typename T> ostream &operator<<(ostream &os, vc<T> &vec) { // vector 出力 (for dump) os << "{" ; REP(i, 0, SIZE(vec)) os << vec[i] << (i == i_len - 1 ? "" : ", " ); os << "}" ; return os; } template < typename T> ostream &operator>>(ostream &os, vc<T> &vec) { // vector 出力 (inline) REP(i, 0, SIZE(vec)) os << vec[i] << (i == i_len - 1 ? "\n" : " " ); return os; } template < typename T, typename U> istream &operator>>(istream &is, pair<T, U> &pair_var) { // pair 入力 is >> pair_var.first >> pair_var.second; return is; } template < typename T, typename U> ostream &operator<<(ostream &os, pair<T, U> &pair_var) { // pair 出力 os << "(" << pair_var.first << ", " << pair_var.second << ")" ; return os; } // map, um, set, us 出力 template < class T> ostream &out_iter(ostream &os, T &map_var) { os << "{" ; REPI(itr, map_var) { os << *itr; auto itrcp = itr; if (++itrcp != map_var.end()) os << ", " ; } return os << "}" ; } template < typename T, typename U> ostream &operator<<(ostream &os, map<T, U> &map_var) { return out_iter(os, map_var); } template < typename T, typename U> ostream &operator<<(ostream &os, um<T, U> &map_var) { os << "{" ; REPI(itr, map_var) { auto [key, value] = *itr; os << "(" << key << ", " << value << ")" ; auto itrcp = itr; if (++itrcp != map_var.end()) os << ", " ; } os << "}" ; return os; } template < typename T> ostream &operator<<(ostream &os, set<T> &set_var) { return out_iter(os, set_var); } template < typename T> ostream &operator<<(ostream &os, us<T> &set_var) { return out_iter(os, set_var); } template < typename T> ostream &operator<<(ostream &os, pq<T> &pq_var) { pq<T> pq_cp(pq_var); os << "{" ; if (!pq_cp.empty()) { os << pq_cp.top(), pq_cp.pop(); while (!pq_cp.empty()) os << ", " << pq_cp.top(), pq_cp.pop(); } return os << "}" ; } void pprint() { cout << endl; } template < class Head, class ... Tail> void pprint(Head &&head, Tail &&... tail) { cout << head; if ( sizeof ...(Tail) > 0) cout << ' ' ; pprint(move(tail)...); } // dump #define DUMPOUT cerr void dump_func() { DUMPOUT << endl; } template < class Head, class ... Tail> void dump_func(Head &&head, Tail &&... tail) { DUMPOUT << head; if ( sizeof ...(Tail) > 0) DUMPOUT << ", " ; dump_func(move(tail)...); } // chmax (更新「される」かもしれない値が前) template < typename T, typename U, typename Comp = less<>> bool chmax(T &xmax, const U &x, Comp comp = {}) { if (comp(xmax, x)) { xmax = x; return true ; } return false ; } // chmin (更新「される」かもしれない値が前) template < typename T, typename U, typename Comp = less<>> bool chmin(T &xmin, const U &x, Comp comp = {}) { if (comp(x, xmin)) { xmin = x; return true ; } return false ; } // ローカル用 #ifndef ONLINE_JUDGE #define DEBUG_ #endif #ifdef DEBUG_ #define DEB #define dump(...) \ DUMPOUT << " " << string(#__VA_ARGS__) << ": " \ << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl \ << " " , \ dump_func(__VA_ARGS__) #else #define DEB if (false) #define dump(...) #endif #define VAR(type, ...) \ type __VA_ARGS__; \ cin >> __VA_ARGS__; template < typename T> istream &operator,(istream &is, T &rhs) { return is >> rhs; } template < typename T> ostream &operator,(ostream &os, const T &rhs) { return os << ' ' << rhs; } struct AtCoderInitialize { static constexpr int IOS_PREC = 15; static constexpr bool AUTOFLUSH = false ; AtCoderInitialize() { ios_base::sync_with_stdio( false ), cin.tie(nullptr), cout.tie(nullptr); cout << fixed << setprecision(IOS_PREC); if (AUTOFLUSH) cout << unitbuf; } } ATCODER_INITIALIZE; void Yn( bool p) { cout << (p ? "Yes" : "No" ) << endl; } void YN( bool p) { cout << (p ? "YES" : "NO" ) << endl; } /* #endregion */ // #include <atcoder/all> // using namespace atcoder; // Problem void solve() { VAR(ll, n); vll ls; map<ll, ll> mp; ll i = 1; while (i * i < n) { ls.push_back(i * i); mp[i * i] = i; ++i; } for (ll x2 : ls) { auto it = lower_bound(ALL(ls), n - x2); if (it != ls.end() && *it == n - x2) { pprint(mp[x2], mp[n - x2]); return ; } } } // entry point int main() { solve(); return 0; } |
ステータス
項目 | データ |
---|---|
問題 | 0001 - さらば2020、ようこそ2021 |
ユーザー名 | abb |
投稿日時 | 2020-12-30 00:07:11 |
言語 | C++17 |
状態 | Accepted |
得点 | 100 |
ソースコード長 | 7137 Byte |
最大実行時間 | 442 ms |
最大メモリ使用量 | 96492 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 100 / 100 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
in01.txt | AC | 126 ms | 29512 KB |
1
|
in02.txt | AC | 315 ms | 68536 KB |
1
|
in03.txt | AC | 252 ms | 57860 KB |
1
|
in04.txt | AC | 268 ms | 61336 KB |
1
|
in05.txt | AC | 359 ms | 83640 KB |
1
|
in06.txt | AC | 264 ms | 58816 KB |
1
|
in07.txt | AC | 316 ms | 72508 KB |
1
|
in08.txt | AC | 152 ms | 36468 KB |
1
|
in09.txt | AC | 179 ms | 43244 KB |
1
|
in10.txt | AC | 40 ms | 6960 KB |
1
|
in11.txt | AC | 181 ms | 45812 KB |
1
|
in12.txt | AC | 229 ms | 51820 KB |
1
|
in13.txt | AC | 346 ms | 84692 KB |
1
|
in14.txt | AC | 213 ms | 54208 KB |
1
|
in15.txt | AC | 224 ms | 60664 KB |
1
|
in16.txt | AC | 370 ms | 95860 KB |
1
|
in17.txt | AC | 368 ms | 84040 KB |
1
|
in18.txt | AC | 274 ms | 61184 KB |
1
|
in19.txt | AC | 251 ms | 57320 KB |
1
|
in20.txt | AC | 340 ms | 72020 KB |
1
|
in21.txt | AC | 256 ms | 58888 KB |
1
|
in22.txt | AC | 318 ms | 70444 KB |
1
|
in23.txt | AC | 91 ms | 22444 KB |
1
|
in24.txt | AC | 195 ms | 45504 KB |
1
|
in25.txt | AC | 321 ms | 69928 KB |
1
|
in26.txt | AC | 213 ms | 50272 KB |
1
|
in27.txt | AC | 307 ms | 57384 KB |
1
|
in28.txt | AC | 119 ms | 27064 KB |
1
|
in29.txt | AC | 102 ms | 24656 KB |
1
|
in30.txt | AC | 233 ms | 56264 KB |
1
|
in31.txt | AC | 388 ms | 87440 KB |
1
|
in32.txt | AC | 341 ms | 83124 KB |
1
|
in33.txt | AC | 285 ms | 63884 KB |
1
|
in34.txt | AC | 374 ms | 83184 KB |
1
|
in35.txt | AC | 255 ms | 57844 KB |
1
|
in36.txt | AC | 378 ms | 84376 KB |
1
|
in37.txt | AC | 258 ms | 60076 KB |
1
|
in38.txt | AC | 298 ms | 67816 KB |
1
|
in39.txt | AC | 305 ms | 64380 KB |
1
|
in40.txt | AC | 118 ms | 26204 KB |
1
|
in41.txt | AC | 228 ms | 53892 KB |
1
|
in42.txt | AC | 295 ms | 65500 KB |
1
|
in43.txt | AC | 154 ms | 36536 KB |
1
|
in44.txt | AC | 128 ms | 30496 KB |
1
|
in45.txt | AC | 268 ms | 58872 KB |
1
|
in46.txt | AC | 195 ms | 48768 KB |
1
|
in47.txt | AC | 250 ms | 54016 KB |
1
|
in48.txt | AC | 229 ms | 51700 KB |
1
|
in49.txt | AC | 140 ms | 34876 KB |
1
|
in50.txt | AC | 273 ms | 61744 KB |
1
|
in51.txt | AC | 415 ms | 87740 KB |
1
|
in52.txt | AC | 288 ms | 63784 KB |
1
|
in53.txt | AC | 109 ms | 26196 KB |
1
|
in54.txt | AC | 176 ms | 43512 KB |
1
|
in55.txt | AC | 201 ms | 50348 KB |
1
|
in56.txt | AC | 148 ms | 34288 KB |
1
|
in57.txt | AC | 396 ms | 84948 KB |
1
|
in58.txt | AC | 256 ms | 56356 KB |
1
|
in59.txt | AC | 250 ms | 58492 KB |
1
|
in60.txt | AC | 442 ms | 96492 KB |
1
|
sample01.txt | AC | 19 ms | 732 KB |
1
|
sample02.txt | AC | 17 ms | 688 KB |
1
|