結果

問題 No.1647 Travel in Mitaru city 2
ユーザー ぷらぷら
提出日時 2021-08-13 22:31:52
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 1,749 bytes
コンパイル時間 2,417 ms
コンパイル使用メモリ 209,880 KB
実行使用メモリ 814,816 KB
最終ジャッジ日時 2024-04-14 18:49:15
合計ジャッジ時間 5,448 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    int H,W,N;
    cin >> H >> W >> N;
    vector<bitset<100000>>tmp(100000);
    vector<vector<int>>dist(100000);
    vector<int>res(100000);
    map<pair<int,int>,int>ans;
    for(int i = 0; i < N; i++) {
        int x,y;
        cin >> x >> y;
        x--;
        y--;
        ans[{x,y}] = i+1;
        dist[y].push_back(x);
        res[x]++;
        tmp[x][y] = 1;
    }
    for(int i = 0; i < 100000; i++) {
        if(dist[i].size() == 0) {
            continue;
        }
        bitset<100000>flag;
        int sum = 0;
        for(int j = 0; j < dist[i].size(); j++) {
            tmp[dist[i][j]][i] = 0;
            flag |= tmp[dist[i][j]];
            sum += res[dist[i][j]];
            if(flag.count() != sum) {
                flag = tmp[dist[i][j]];
                sum = res[dist[i][j]];
                for(int k = j-1; k >= 0; k--) {
                    flag |= tmp[dist[i][j]];
                    sum += res[dist[i][j]];
                    if(flag.count() != sum) {
                        flag = tmp[dist[i][j]]|tmp[dist[i][k]];
                        for(int l = 0; l < 100000; l++) {
                            if(flag.test(l)) {
                                int x1 = dist[i][j],x2 = dist[i][k];
                                int y1 = j,y2 = l;
                                cout << 4 << endl;
                                cout << ans[{x1,y1}] << " " << ans[{x2,y1}] << " " << ans[{x2,y2}] << " " << ans[{x1,y2}] << endl;
                                return 0;
                            }
                        }
                    }
                }
            }
            tmp[dist[i][j]][i] = 1;
        }
    }
    cout << -1 << endl;
}
0