結果
問題 | No.74 貯金箱の退屈 |
ユーザー | mai |
提出日時 | 2017-07-01 17:05:47 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 4,831 bytes |
コンパイル時間 | 3,584 ms |
コンパイル使用メモリ | 222,052 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-04 23:37:23 |
合計ジャッジ時間 | 4,066 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,820 KB |
testcase_01 | AC | 2 ms
6,816 KB |
testcase_02 | AC | 2 ms
6,820 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | AC | 1 ms
6,816 KB |
testcase_16 | AC | 2 ms
6,816 KB |
testcase_17 | AC | 1 ms
6,816 KB |
testcase_18 | AC | 2 ms
6,820 KB |
testcase_19 | AC | 1 ms
6,820 KB |
testcase_20 | AC | 2 ms
6,816 KB |
testcase_21 | AC | 1 ms
6,820 KB |
testcase_22 | AC | 2 ms
6,820 KB |
testcase_23 | AC | 2 ms
6,820 KB |
testcase_24 | AC | 2 ms
6,820 KB |
testcase_25 | AC | 2 ms
6,816 KB |
testcase_26 | AC | 2 ms
6,820 KB |
testcase_27 | AC | 2 ms
6,820 KB |
testcase_28 | AC | 1 ms
6,820 KB |
testcase_29 | AC | 1 ms
6,820 KB |
testcase_30 | AC | 2 ms
6,816 KB |
testcase_31 | AC | 2 ms
6,820 KB |
testcase_32 | AC | 2 ms
6,816 KB |
コンパイルメッセージ
main.cpp: In member function '{anonymous}::MaiScanner& {anonymous}::MaiScanner::operator>>(std::string&)': main.cpp:72:9: warning: no return statement in function returning non-void [-Wreturn-type] 72 | } | ^
ソースコード
#pragma GCC optimize ("O3") #pragma GCC target ("avx") #include "bits/stdc++.h" // define macro "/D__MAI" using namespace std; typedef long long int ll; #define debugv(v) printf("L%d %s => ",__LINE__,#v);for(auto e:v){cout<<e<<" ";}cout<<endl; #define debugm(m) printf("L%d %s is..\n",__LINE__,#m);for(auto v:m){for(auto e:v){cout<<e<<" ";}cout<<endl;} #define debuga(m,w) printf("L%d %s is => ",__LINE__,#m);for(int x=0;x<(w);x++){cout<<(m)[x]<<" ";}cout<<endl; #define debugaa(m,w,h) printf("L%d %s is..\n",__LINE__,#m);for(int y=0;y<(h);y++){for(int x=0;x<(w);x++){cout<<(m)[x][y]<<" ";}cout<<endl;} #define debugaar(m,w,h) printf("L%d %s is..\n",__LINE__,#m);for(int y=0;y<(h);y++){for(int x=0;x<(w);x++){cout<<(m)[y][x]<<" ";}cout<<endl;} #define ALL(v) (v).begin(),(v).end() #define repeat(l) for(auto cnt=0;cnt<(l);++cnt) #define iterate(b,e) for(auto cnt=(b);cnt!=(e);++cnt) #define MD 1000000007ll #define PI 3.1415926535897932384626433832795 template<typename T1, typename T2> ostream& operator <<(ostream &o, const pair<T1, T2> p) { o << "(" << p.first << ":" << p.second << ")"; return o; } #define TIME chrono::system_clock::now() #define MILLISEC(t) (chrono::duration_cast<chrono::milliseconds>(t).count()) namespace { std::chrono::system_clock::time_point ttt; void tic() { ttt = TIME; } void toc() { fprintf(stderr, "TIME : %lldms\n", MILLISEC(TIME - ttt)); } std::chrono::system_clock::time_point tle = TIME; #ifdef __MAI void safe_tle(int msec) { assert(MILLISEC(TIME - tle) < msec); } #else #define safe_tle(k) ; #endif } #ifdef __MAI #define getchar_unlocked getchar #define putchar_unlocked putchar #endif #ifdef __VSCC #define getchar_unlocked _getchar_nolock #define putchar_unlocked _putchar_nolock #endif namespace { #define isvisiablechar(c) (0x21<=(c)&&(c)<=0x7E) class MaiScanner { public: template<typename T> void input_integer(T& var) { var = 0; T sign = 1; int cc = getchar_unlocked(); for (; cc<'0' || '9'<cc; cc = getchar_unlocked()) if (cc == '-') sign = -1; for (; '0' <= cc&&cc <= '9'; cc = getchar_unlocked()) var = (var << 3) + (var << 1) + cc - '0'; var = var*sign; } inline int c() { return getchar_unlocked(); } inline MaiScanner& operator>>(int& var) { input_integer<int>(var); return *this; } inline MaiScanner& operator>>(long long& var) { input_integer<long long>(var); return *this; } inline MaiScanner& operator>>(string& var) { int cc = getchar_unlocked(); for (; !isvisiablechar(cc); cc = getchar_unlocked()); for (; isvisiablechar(cc); cc = getchar_unlocked()) var.push_back(cc); } }; } MaiScanner scanner; int n; int dd[111]; int ww[111]; int main() { scanner >> n; repeat(n) { scanner >> dd[cnt]; } repeat(n) { scanner >> ww[cnt]; ww[cnt]^=1; } vector<int> pivot(n); repeat(n){pivot[cnt]=cnt;} vector<valarray<int>> mat_s(n, valarray<int>(n)); valarray<int> vec_r(n); for (int i = 0; i<n; ++i) { vec_r[i] = ww[i]; } for (int i = 0; i < n; ++i) { int l = ((i - dd[i]) % n + n) % n; int r = (i + dd[i]) % n; mat_s[i][l] = 1; mat_s[i][r] = 1; } // debugaar(mat_s,n,n) // debugv(vec_r) for (int i = 0; i<n; ++i) {// yoko // pivot if (mat_s[i][i] == 0) { for (int j = i + 1; j<n; j++) { if (mat_s[j][i] == 1) { mat_s[j].swap(mat_s[i]); //mat_r[j].swap(mat_r[i]); swap(vec_r[i], vec_r[j]); swap(pivot[i], pivot[j]); break; } } // printf("swap\n"); // debugaar(mat_s,n,n) // debugv(vec_r) } for (int j = 0; j<n; j++) { // tate if (i == j) continue; if (mat_s[j][i] == 0) continue; mat_s[j] ^= mat_s[i]; vec_r[j] ^= vec_r[i]; } // debugaar(mat_s,n,n) // debugv(vec_r) // cout <<endl; } //debugv(vec_r) // simulate for (int ii = 0; ii < n; ++ii) { int i = ii;//pivot[ii]; if (!vec_r[i]) continue; int ll = ((i - dd[i]) % n + n) % n; int rr = (i + dd[i]) % n; int l = pivot[ll]; int r = pivot[rr]; ww[l] ^= 1; if (l != r) ww[r] ^= 1; } //debuga(ww,n) int a = accumulate(ww, ww + n, 0); if (a == n || a==0) cout << "Yes" << endl; else cout << "No" << endl; return 0; }