結果
| 問題 |
No.1647 Travel in Mitaru city 2
|
| コンテスト | |
| ユーザー |
Nachia
|
| 提出日時 | 2021-08-13 22:46:47 |
| 言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,438 bytes |
| コンパイル時間 | 3,072 ms |
| コンパイル使用メモリ | 122,288 KB |
| 最終ジャッジ日時 | 2025-01-23 20:30:09 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 2 WA * 46 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#include <atcoder/modint>
#include <atcoder/fenwicktree>
using namespace std;
using i64 = int64_t;
using u64 = uint64_t;
#define rep(i,n) for(int i=0; i<(n); i++)
int H,W,N;
vector<int> solve(vector<pair<int,int>> P){
vector<int> ans;
vector<vector<int>> E(W);
vector<vector<int>> D(H);
rep(i,N){
auto p = P[i];
E[p.second].push_back(i);
D[p.first].push_back(i);
}
rep(x,H){
vector<int> YI;
for(auto i : D[x]){
int y = P[i].second;
if(E[y].size() >= 2) YI.push_back(i);
}
if(YI.size() < 2) continue;
ans.resize(4);
ans[1] = YI[0];
ans[2] = YI[1];
for(int e : E[P[YI[0]].second]) if(e != YI[0]) ans[0] = e;
for(int e : E[P[YI[1]].second]) if(e != YI[1]) ans[3] = e;
return ans;
}
return ans;
}
int main() {
cin >> H >> W >> N;
vector<pair<int,int>> P(N);
rep(i,N){
int y,x; cin >> y >> x; y--; x--;
P[i] = {y,x};
}
vector<int> ans;
//rep(t,2){
//rep(i,N) swap(P[i].first,P[i].second);
//swap(H,W);
ans = solve(P);
//if(!ans.empty()) break;
//}
if(ans.empty()){
cout << "-1\n";
}
else{
cout << "4\n";
rep(i,4){
if(i) cout << " ";
cout << (ans[i]+1);
}
cout << "\n";
}
return 0;
}
struct ios_do_not_sync{
ios_do_not_sync(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
}
} ios_do_not_sync_instance;
Nachia