結果
問題 | No.483 マッチ並べ |
ユーザー |
|
提出日時 | 2017-02-10 22:51:10 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 1,401 bytes |
コンパイル時間 | 1,171 ms |
コンパイル使用メモリ | 94,332 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-29 08:11:37 |
合計ジャッジ時間 | 2,960 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 53 |
ソースコード
#include "iostream"#include "climits"#include "list"#include "queue"#include "stack"#include "set"#include "functional"#include "algorithm"#include "math.h"#include "utility"#include "map"using namespace std;const long long int MOD = 1000000007;typedef pair<int, int> P;int N;int place[111][111];bool flag[111][111];int a, b,c,d;P current;queue<P>Q;int dx[4] = { 1,0,-1,0 };int dy[4] = { 0,1,0,-1 };int edge;int node;int main() {cin >> N;for (int i = 0; i < N; i++) {cin >> a >> b >> c >> d;place[a][b]++;place[c][d]++;}for (int i = 1; i < 101; i++) {for (int j = 1; j < 101; j++) {if (place[i][j]) {flag[i][j] = true;}}}for (int i = 1; i < 101; i++) {for (int j = 1; j < 101; j++) {if (flag[i][j]) {edge = place[i][j];node = 1;flag[i][j] = false;current.first = i;current.second = j;Q.push(current);while (!Q.empty()) {for (int k = 0; k < 4; k++) {current.first = Q.front().first + dy[k];current.second = Q.front().second + dx[k];if (flag[current.first][current.second]) {flag[current.first][current.second] = false;node++;edge += place[current.first ][current.second];Q.push(current);}}Q.pop();}if (edge / 2 > node) {cout << "NO\n";return 0;}}}}cout << "YES\n";return 0;}