結果
問題 | No.1665 quotient replace |
ユーザー | oliverx3 |
提出日時 | 2021-09-03 21:55:12 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 2,266 ms / 3,000 ms |
コード長 | 7,748 bytes |
コンパイル時間 | 4,806 ms |
コンパイル使用メモリ | 268,528 KB |
実行使用メモリ | 227,920 KB |
最終ジャッジ日時 | 2024-05-09 03:42:54 |
合計ジャッジ時間 | 96,886 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1,916 ms
224,288 KB |
testcase_01 | AC | 1,904 ms
224,200 KB |
testcase_02 | AC | 1,867 ms
224,196 KB |
testcase_03 | AC | 1,925 ms
224,156 KB |
testcase_04 | AC | 1,938 ms
224,412 KB |
testcase_05 | AC | 1,948 ms
224,292 KB |
testcase_06 | AC | 1,892 ms
224,288 KB |
testcase_07 | AC | 1,930 ms
224,288 KB |
testcase_08 | AC | 1,916 ms
224,288 KB |
testcase_09 | AC | 1,882 ms
224,416 KB |
testcase_10 | AC | 1,993 ms
225,444 KB |
testcase_11 | AC | 2,183 ms
226,976 KB |
testcase_12 | AC | 1,971 ms
224,292 KB |
testcase_13 | AC | 2,235 ms
227,876 KB |
testcase_14 | AC | 2,200 ms
227,916 KB |
testcase_15 | AC | 2,266 ms
227,916 KB |
testcase_16 | AC | 2,213 ms
227,920 KB |
testcase_17 | AC | 2,246 ms
227,852 KB |
testcase_18 | AC | 1,946 ms
224,196 KB |
testcase_19 | AC | 1,932 ms
224,288 KB |
testcase_20 | AC | 1,948 ms
224,416 KB |
testcase_21 | AC | 1,942 ms
224,196 KB |
testcase_22 | AC | 1,952 ms
224,288 KB |
testcase_23 | AC | 1,923 ms
224,284 KB |
testcase_24 | AC | 1,945 ms
224,292 KB |
testcase_25 | AC | 1,947 ms
224,288 KB |
testcase_26 | AC | 1,957 ms
224,288 KB |
testcase_27 | AC | 1,943 ms
224,292 KB |
testcase_28 | AC | 1,944 ms
224,288 KB |
testcase_29 | AC | 1,955 ms
224,312 KB |
testcase_30 | AC | 2,061 ms
225,956 KB |
testcase_31 | AC | 2,118 ms
227,104 KB |
testcase_32 | AC | 2,121 ms
226,844 KB |
testcase_33 | AC | 1,978 ms
225,188 KB |
testcase_34 | AC | 2,140 ms
226,324 KB |
testcase_35 | AC | 2,110 ms
226,080 KB |
testcase_36 | AC | 2,090 ms
226,336 KB |
testcase_37 | AC | 2,056 ms
226,084 KB |
testcase_38 | AC | 2,123 ms
226,336 KB |
testcase_39 | AC | 2,078 ms
225,820 KB |
testcase_40 | AC | 2,091 ms
225,824 KB |
testcase_41 | AC | 2,073 ms
225,700 KB |
testcase_42 | AC | 1,941 ms
224,288 KB |
testcase_43 | AC | 1,943 ms
224,288 KB |
ソースコード
/** * author: oliverx3 * created: 03.09.2021 21:25:55 **/ #include <bits/stdc++.h> #if __has_include(<atcoder/all>) #include <atcoder/all> #endif #pragma region header #pragma region alias using lint = long long; using ll = long long; using P = std::pair<long, long>; template<class T> using prique = std::priority_queue<T,std::vector<T>,std::greater<T>>; #pragma endregion #pragma region macros #define rep(i, n) for(ll i = 0;i<(ll)(n);i++) #define REP(i, m, n) for(ll i = (m);i<(ll)(n);i++) #define drep(i, n) for(ll i = (n)-1;i>=0;i--) #define DREP(i, m, n) for(ll i = (m)-1;i>=(ll)(n);i--) #define all(v) (v).begin(),(v).end() #define reall(v) (v).rbegin(),(v).rend() template<class T, class U> bool chmax(T& a,const U b) { if(a < b) { a = b; return true; } return false; } template<class T, class U> bool chmin(T& a,const U b) { if(a>b) { a = b; return true; } return false; } bool is_flag(const long long &bit, const int &k) { return (bit >> k)&1; } #pragma endregion #pragma region constant constexpr int inf = 1<<30; constexpr long long INF = 1LL << 61; constexpr long double eps = 1e-10; constexpr long double pi = 3.141592653589793238; constexpr int dx[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0}; constexpr int dy[9] = {0, 1, 0, -1, 1, -1, 1, -1, 0}; constexpr long long mod = 1e9+7; constexpr long long MOD = 998244353; #pragma endregion #pragma region inout template<class T> std::ostream& operator<<(std::ostream& stream, const std::vector<T>& v) { for(int i = 0; i < (int)(v.size()); i++) { stream << v[i]; if(i != (int)(v.size()) - 1) stream << ' '; } return stream; } template<typename Itr> inline void print(const Itr& begin, const Itr& end, bool endline = true, const char* BEGIN = "{", const char* mid = ", ", const char* END = "}") { if(begin == end) return; std::cout << BEGIN << *begin; for(Itr itr = begin+1; itr < end; itr++) std::cout << mid << *itr; std::cout << END; if(endline) std::endl(std::cout); return; } template<class T> std::istream& operator>>(std::istream& stream, std::vector<T>& v) { for(T& p:v) stream >> p; return stream; } template<typename Itr> inline void input(Itr begin, Itr end) { for(Itr& itr = begin; itr < end; itr++) std::cin >> *itr; return; } template<class T, class U> std::ostream& operator<<(std::ostream& stream, const std::pair<T,U>& pair) { return stream << pair.first << ' ' << pair.second; } template<class T, class U> inline void print(const std::pair<T,U>& pair,const bool endline = true, const char* begin = "(", const char* mid = ", ", const char* end = ")") { std::cout << begin << pair.first << mid << pair.second << end; if(endline) std::endl(std::cout); else std::cout << ' '; return; } template<class T, class U> std::istream& operator>>(std::istream& stream, std::pair<T,U>& pair) { return stream >> pair.first >> pair.second; } template<class T, class U> inline void input(std::pair<T,U>& pair, const bool first = true, const bool second = true) { if(first) std::cin >> pair.first; if(second) std::cin >> pair.second; } #pragma endregion #pragma region DEBUG #ifdef _DEBUG template<class T> inline void _debug_view(const T& x) noexcept; template<class T, class U> inline void _debug_view(const std::pair<T,U>& p) noexcept; template<class T> inline void _debug_view(const std::vector<T>& v) noexcept; template<class T> inline void _debug_view(const std::vector<std::vector<T>>& v) noexcept; template<class T, class U> inline void _debug_view(const std::map<T,U>& mp) noexcept; template<class T> inline void _debug_view(const std::set<T>& st) noexcept; template<class T> inline void _debug_view(const T& x) noexcept { std::cout << x; return; } template<class T, class U> inline void _debug_view(const std::pair<T,U>& p) noexcept { std::cout << "("; _debug_view(p.first); std::cout << ", "; _debug_view(p.second); std::cout << ")"; return; } template<class T> inline void _debug_view(const std::vector<T>& v) noexcept { std::cout << "{"; for(int i = 0;i<v.size();i++) { _debug_view(v[i]); std::cout << (i+1 == v.size() ? "" : ", "); } std::cout << "}"; return; } template<class T> inline void _debug_view(const std::vector<std::vector<T>>& v) noexcept { std::cout << "{\n"; for(int i = 0; i < (int)(v.size()); i++) { _debug_view(v[i]); std::cout << (i + 1 == (int)(v.size()) ? "\n" : ",\n"); } std::cout << "}"; return; } template<class T, class U> inline void _debug_view(const std::map<T,U>& mp) noexcept { std::cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) { const std::pair<T, U> itr_val = *itr; _debug_view(itr_val); if(std::next(itr) != mp.end()) std::cout << ", "; } std::cout << "}"; return; } template<class T> inline void _debug_view(const std::set<T>& st) noexcept { std::cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) { const T itr_val = *itr; _debug_view(itr_val); if(std::next(itr) != st.end()) std::cout << ", "; } std::cout << "}"; return; } #define overload5(_1,_2,_3,_4,_5,name,...) name #define _debug1(a) {\ do {\ std::cout << #a << ": ";\ _debug_view(a);\ std::endl(std::cout);\ }while(0);\ } #define _debug2(a,b) {\ do {\ std::cout << #a << ": ";\ _debug_view(a);\ std::cout << ", " << #b << ": ";\ _debug_view(b);\ std::endl(std::cout);\ }while(0);\ } #define _debug3(a,b,c) {\ do {\ std::cout << #a << ": ";\ _debug_view(a);\ std::cout << ", " << #b << ": ";\ _debug_view(b);\ std::cout << ", " << #c << ": ";\ _debug_view(c);\ std::endl(std::cout);\ }while(0);\ } #define _debug4(a,b,c,d) {\ do {\ std::cout << #a << ": ";\ _debug_view(a);\ std::cout << ", " << #b << ": ";\ _debug_view(b);\ std::cout << ", " << #c << ": ";\ _debug_view(c);\ std::cout << ", " << #d << ": ";\ _debug_view(d);\ std::endl(std::cout);\ }while(0);\ } #define _debug5(a,b,c,d,e) {\ do {\ std::cout << #a << ": ";\ _debug_view(a);\ std::cout << ", " << #b << ": ";\ _debug_view(b);\ std::cout << ", " << #c << ": ";\ _debug_view(c);\ std::cout << ", " << #d << ": ";\ _debug_view(d);\ std::cout << ", " << #e << ": ";\ _debug_view(e);\ std::endl(std::cout);\ }while(0);\ } #define debug(...) overload5(__VA_ARGS__,_debug5,_debug4,_debug3,_debug2,_debug1,)(__VA_ARGS__) #else #define debug(...) #endif #pragma endregion #pragma endregion int mex(const std::set<int> &st) { int res = 0; while(st.count(res)) res++; return res; } std::set<int> st[1'000'001]; int grundy_check[1'000'001]; int grundy(int n) { if(grundy_check[n] != -1) return grundy_check[n]; return grundy_check[n] = mex(st[n]); } void dfs(const int now) { // debug(now); const int g = grundy(now); int cur = now*2; while(cur <= 1'000'000) { st[cur].insert(g); cur+=now; } return; } int main() { std::fill(grundy_check, grundy_check+1'000'001, -1); int n; std::cin >> n; std::vector<int> a(n); std::cin >> a; grundy_check[1] = 0; REP(i, 1, 1'000'001) { dfs(i); debug(i); // std::cout << i << std::endl; } int nimber = 0; for(const auto &p:a) nimber ^= grundy(p); std::cout << (nimber?"white":"black") << std::endl; return 0; }