結果

問題 No.483 マッチ並べ
ユーザー BantakoBantako
提出日時 2018-06-18 21:54:53
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,907 bytes
コンパイル時間 1,554 ms
コンパイル使用メモリ 169,932 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-30 17:05:18
合計ジャッジ時間 3,113 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 53
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    8 | main(){
      | ^~~~

ソースコード

diff #

#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){   
    int field[110][110] = {};
    int nodep[110][110] = {};
    int N;
    cin >> N;
    int V[N][4];
    rep(i,0,N){
        cin >> V[i][0] >> V[i][1] >> V[i][2] >> V[i][3];
        field[ V[i][0] ][ V[i][1] ]++;
        field[ V[i][2] ][ V[i][3] ]++;
        //int dif = (V[i][0] - V[i][2] + 3)/2 + (V[i][1] - V[i][3] + 3)*2;
        int dif = 0;
        if(V[i][0] != V[i][2])dif = V[i][0] > V[i][2] ? 1 : 2;
        else                  dif = V[i][1] > V[i][3] ? 4 : 8;
        nodep[ V[i][0] ][ V[i][1] ] += dif;
        nodep[ V[i][2] ][ V[i][3] ] += (dif&2||dif&8 ? dif/2 : dif*2);
    }
        /*                  
        cout  << endl;
        rep(i,1,12)rep(j,1,12){
            cout << field[i][j] << " \n"[j==11];
        }  
        cout << endl;
                          */
    while(1){
        bool update = 0;
        rep(i,1,101)rep(j,1,101){
            if(field[i][j] == 1){
                update = 1;
                int dy[] = {-1,1,0,0} , dx[] = {0,0,-1,1};
                int ind = (int)log2(nodep[i][j]);
                int np = nodep[i][j];
                field[ i + dy[ind] ][ j + dx[ind] ]--;
                field[i][j]--;
                nodep[ i + dy[ind] ][ j + dx[ind] ] -= (np&2||np&8 ? np/2 : np*2);
                nodep[i][j] = 0;
                
            }
        }
        /*                  
        rep(i,1,12)rep(j,1,12){
            cout << field[i][j] << " \n"[j==11];
        }  
                          */
        if(!update)break;
    }
    //最大値が3以上ならNG
    int maxi = 0;
    rep(i,1,101)rep(j,1,101){
        maxi = max(maxi, field[i][j]);
    }
    if(maxi >= 3) cout << "NO" << endl;
    else          cout << "YES" << endl;

}
0