# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
577508 | AQT | Furniture (JOI20_furniture) | C++14 | 3 ms | 852 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int N, M;
bool tkn[1005][1005];
pair<int, int> dsu[1005][1005];
pair<int, int> getrt(pair<int, int> p) {
auto q = dsu[p.first][p.second];
if(q == p) {
return q;
}
return dsu[p.first][p.second] = getrt(q);
}
void upd(int i, int j) {
if(i >= 1 && i <= N && j >= 1 && j <= M) {
if(!tkn[i][j]) {
tkn[i][j] = 1;
//cout << getrt(make_pair(i-1, j)).first << " " << getrt(make_pair(i-1, j)).second << " " << getrt(make_pair(i, j)).first << " " << getrt(make_pair(i, j)).second << "\n";
if(tkn[i-1][j] && getrt(make_pair(i-1, j)) != getrt(make_pair(i, j))) {
auto p = getrt(make_pair(i, j));
dsu[p.first][p.second] = getrt(make_pair(i-1, j));
//cout << "here" << endl;
}
if(tkn[i][j-1] && getrt(make_pair(i, j-1)) != getrt(make_pair(i, j))) {
auto p = getrt(make_pair(i, j));
dsu[i][j] = getrt(make_pair(i, j-1));
//cout << "here" << endl;
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |