結果
問題 | No.455 冬の大三角 |
ユーザー | ManjushriMitra |
提出日時 | 2024-08-10 11:11:35 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,861 bytes |
コンパイル時間 | 3,095 ms |
コンパイル使用メモリ | 248,412 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-08-10 11:11:41 |
合計ジャッジ時間 | 6,495 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
5,376 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | RE | - |
testcase_04 | AC | 2 ms
6,944 KB |
testcase_05 | AC | 2 ms
6,944 KB |
testcase_06 | AC | 2 ms
6,944 KB |
testcase_07 | AC | 1 ms
6,944 KB |
testcase_08 | AC | 3 ms
6,944 KB |
testcase_09 | RE | - |
testcase_10 | AC | 2 ms
6,944 KB |
testcase_11 | RE | - |
testcase_12 | AC | 1 ms
6,944 KB |
testcase_13 | AC | 2 ms
6,940 KB |
testcase_14 | RE | - |
testcase_15 | AC | 2 ms
6,940 KB |
testcase_16 | AC | 2 ms
6,948 KB |
testcase_17 | AC | 1 ms
6,940 KB |
testcase_18 | WA | - |
testcase_19 | AC | 2 ms
6,940 KB |
testcase_20 | AC | 2 ms
6,940 KB |
testcase_21 | RE | - |
testcase_22 | AC | 2 ms
6,940 KB |
testcase_23 | AC | 2 ms
6,940 KB |
testcase_24 | AC | 2 ms
6,944 KB |
testcase_25 | AC | 2 ms
6,940 KB |
testcase_26 | AC | 1 ms
6,944 KB |
testcase_27 | AC | 2 ms
6,940 KB |
testcase_28 | RE | - |
testcase_29 | AC | 2 ms
6,940 KB |
testcase_30 | AC | 2 ms
6,940 KB |
testcase_31 | AC | 2 ms
6,940 KB |
testcase_32 | AC | 2 ms
6,940 KB |
testcase_33 | AC | 2 ms
6,940 KB |
testcase_34 | AC | 2 ms
6,944 KB |
testcase_35 | AC | 2 ms
6,944 KB |
testcase_36 | AC | 2 ms
6,944 KB |
testcase_37 | AC | 2 ms
6,944 KB |
testcase_38 | AC | 2 ms
6,944 KB |
testcase_39 | AC | 3 ms
6,940 KB |
testcase_40 | AC | 2 ms
6,940 KB |
testcase_41 | AC | 3 ms
6,940 KB |
testcase_42 | AC | 2 ms
6,940 KB |
testcase_43 | AC | 2 ms
6,940 KB |
testcase_44 | AC | 2 ms
6,940 KB |
testcase_45 | AC | 2 ms
6,944 KB |
testcase_46 | AC | 2 ms
6,940 KB |
testcase_47 | AC | 2 ms
6,940 KB |
testcase_48 | AC | 2 ms
6,944 KB |
testcase_49 | AC | 2 ms
6,940 KB |
testcase_50 | AC | 2 ms
6,940 KB |
testcase_51 | AC | 2 ms
6,944 KB |
testcase_52 | RE | - |
testcase_53 | AC | 2 ms
6,944 KB |
testcase_54 | AC | 2 ms
6,940 KB |
testcase_55 | AC | 2 ms
6,940 KB |
testcase_56 | AC | 2 ms
6,944 KB |
コンパイルメッセージ
main.cpp: In function 'int main()': main.cpp:72:32: warning: 'ans_x' may be used uninitialized [-Wmaybe-uninitialized] 72 | if(y == ans_y && x == ans_x) cout << "*"; | ~~^~~~~~~~ main.cpp:37:16: note: 'ans_x' was declared here 37 | int ans_y, ans_x; | ^~~~~ main.cpp:72:18: warning: 'ans_y' may be used uninitialized [-Wmaybe-uninitialized] 72 | if(y == ans_y && x == ans_x) cout << "*"; | ~~^~~~~~~~ main.cpp:37:9: note: 'ans_y' was declared here 37 | int ans_y, ans_x; | ^~~~~
ソースコード
#include<bits/stdc++.h> using namespace std; using ll = long long; #define rep(i,m,n) for(int i=m; i<n; ++i) #define repl(i,m,n) for(ll i=m; i<n; ++i) #define all(a) (a).begin(), (a).end() #define rall(a) (a).rbegin(), (a).rend() int gcd(int a, int b){ return a % b ? gcd(b, a % b) : b; } pair<int, int> slope(int y1, int x1, int y2, int x2){ int y = y2 - y1, x = x2 - x1; int g = gcd(abs(y), abs(x)); return {y/g, x/g}; } int main(){ int H, W; cin >> H >> W; vector<string> S(H); rep(i, 0, H) cin >> S[i]; int x1 = -1, y1 = -1, x2 = -1, y2 = -1; rep(y, 0, H) rep(x, 0, W){ if(S[y][x] == '*'){ if(x1 == -1){ x1 = x, y1 = y; }else{ x2 = x, y2 = y; break; } } } int ans_y, ans_x; if(y1 == y2){ rep(y, 0, H) rep(x, 0, W){ if(y == y1 && x == x1) continue; if(y == y2 && x == x2) continue; if(y != y1){ ans_y = y, ans_x = x; break; } } }else if(x1 == x2){ rep(y, 0, H) rep(x, 0, W){ if(y == y1 && x == x1) continue; if(y == y2 && x == x2) continue; if(x != x1){ ans_y = y, ans_x = x; break; } } }else{ auto s1 = slope(y1, x1, y2, x2); rep(y, 0, H) rep(x, 0, W){ if(y == y1 && x == x1) continue; if(y == y2 && x == x2) continue; auto s = slope(y, x, y1, x1); if(s != s1){ ans_y = y, ans_x = x; break; } } } rep(y, 0, H){ rep(x, 0, W){ if(y == ans_y && x == ans_x) cout << "*"; else cout << S[y][x]; } cout << endl; } return 0; }