Submission #26776528
Source Code Expand
#include<bits/stdc++.h> using namespace std; int H, W, N; multiset<int> row[200005], col[200005]; struct Node { int r, c, x, i; }; map<int, vector<Node>> mp; int ans[200005]; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); cin >> H >> W >> N; vector<Node> a; for(int i=0;i<N;++i) { int r, c, x; cin >> r >> c >> x; a.push_back({r, c, x, i}); if (!mp.count(x)) mp[x] = vector<Node>(); mp[x].push_back({r, c, x, i}); } for(auto it=mp.rbegin();it!=mp.rend();++it) { for(auto a:it->second) { int r = a.r; int c = a.c; int idx = a.i; if (!row[r].empty()) ans[idx] = max(ans[idx], *row[r].rbegin() + 1); if (!col[c].empty()) ans[idx] = max(ans[idx], *col[c].rbegin() + 1); } for(auto a:it->second) { int r = a.r; int c = a.c; int idx = a.i; row[r].insert(ans[idx]); col[c].insert(ans[idx]); } } for(int i=0;i<N;++i) cout << ans[i] << '\n'; }
Submission Info
Submission Time | |
---|---|
Task | E - Integers on Grid |
User | seastar105 |
Language | C++ (GCC 9.2.1) |
Score | 500 |
Code Size | 993 Byte |
Status | AC |
Exec Time | 455 ms |
Memory | 66460 KiB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 500 / 500 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | example0.txt, example1.txt |
All | 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, 024.txt, 025.txt, 026.txt, 027.txt, 028.txt, 029.txt, 030.txt, 031.txt, example0.txt, example1.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
000.txt | AC | 25 ms | 22360 KiB |
001.txt | AC | 198 ms | 46972 KiB |
002.txt | AC | 22 ms | 22252 KiB |
003.txt | AC | 18 ms | 22340 KiB |
004.txt | AC | 18 ms | 22296 KiB |
005.txt | AC | 388 ms | 66428 KiB |
006.txt | AC | 179 ms | 46996 KiB |
007.txt | AC | 188 ms | 47724 KiB |
008.txt | AC | 394 ms | 66276 KiB |
009.txt | AC | 399 ms | 66316 KiB |
010.txt | AC | 391 ms | 65572 KiB |
011.txt | AC | 22 ms | 22264 KiB |
012.txt | AC | 203 ms | 48384 KiB |
013.txt | AC | 450 ms | 66392 KiB |
014.txt | AC | 455 ms | 66440 KiB |
015.txt | AC | 453 ms | 66444 KiB |
016.txt | AC | 231 ms | 48520 KiB |
017.txt | AC | 228 ms | 48544 KiB |
018.txt | AC | 229 ms | 48632 KiB |
019.txt | AC | 227 ms | 47716 KiB |
020.txt | AC | 145 ms | 39188 KiB |
021.txt | AC | 71 ms | 29852 KiB |
022.txt | AC | 298 ms | 56116 KiB |
023.txt | AC | 402 ms | 66456 KiB |
024.txt | AC | 405 ms | 66444 KiB |
025.txt | AC | 406 ms | 66428 KiB |
026.txt | AC | 451 ms | 66392 KiB |
027.txt | AC | 447 ms | 66460 KiB |
028.txt | AC | 450 ms | 66408 KiB |
029.txt | AC | 231 ms | 48660 KiB |
030.txt | AC | 232 ms | 48456 KiB |
031.txt | AC | 231 ms | 48460 KiB |
example0.txt | AC | 26 ms | 22296 KiB |
example1.txt | AC | 18 ms | 22192 KiB |