Submission #224947

# Submission time Handle Problem Language Result Execution time Memory
224947 2020-04-19T06:47:17 Z kartel Konj (COCI19_konj) C++14
0 / 70
240 ms 7800 KB
#include <bits/stdc++.h>
#define in(x) freopen(x,"r",stdin)
#define out(x) freopen(x,"w",stdout)
#define F first
#define S second
#define pb push_back
#define M ll(998244353)
#define inf ll(2e9+7)
#define N ll(200500)
#define sz(x) x.size()
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("Ofast")
#define el '\n'
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree <ll, null_type, less_equal <ll>, rb_tree_tag, tree_order_statistics_node_update> os;

char ans[301][301];
int a[301][301];
int xl[N], xr[N], yl[N], yr[N], pr[N], ra[N], i, j, x, y, k, n, n1, m1;

int f(int x) {return ((pr[x] == x) ? x : (pr[x] = f(pr[x])));}

void link(int x, int y)
{
    x = f(x);
    y = f(y);
    if (x > y) swap(x, y);
    if (ra[x] < ra[y]) pr[x] = y;
    else
    {
        pr[y] = x;
        if (ra[x] == ra[y]) ra[y]++;
    }
}

int main()
{
//    in("input.txt");
//    out("output.txt");

    ios_base::sync_with_stdio(false);
    iostream::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;

    for (i = 1; i <= n; i++) pr[i] = i, ra[i] = 1;

    for (i = 1; i <= n; i++)
    {
        cin >> xl[i] >> yl[i] >> xr[i] >> yr[i];

        if (xl[i] > xr[i]) swap(xl[i], xr[i]);
        if (yl[i] > yr[i]) swap(yl[i], yr[i]);

        for (x = xl[i]; x <= xr[i]; x++)
          for (y = yl[i]; y <= yr[i]; y++)
        {
            if (a[x][y] == 0) a[x][y] = i;
                         else link(a[x][y], i);
        }
    }

    for (i = 0; i <= 300; i++)
      for (j = 0; j <= 300; j++) ans[i][j] = '.';

    cin >> x >> y;

    k = a[x][y];

    for (i = 1; i <= n; i++)
    {
        if (f(i) != f(k)) continue;

        n1 = max(n1, xr[i]);
        m1 = max(m1, yr[i]);

        for (x = xl[i]; x <= xr[i]; x++)
          for (y = yl[i]; y <= yr[i]; y++) ans[y][x] = '#';


    }
        for (i = m1; i >= 0; i--, cerr << el)
            for (j = 0; j <= n1; j++) cerr << ans[i][j];

        cerr << el;

}
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 512 KB Output isn't correct
2 Incorrect 9 ms 512 KB Output isn't correct
3 Incorrect 240 ms 7800 KB Output isn't correct
4 Incorrect 6 ms 512 KB Output isn't correct
5 Incorrect 7 ms 512 KB Output isn't correct
6 Incorrect 7 ms 512 KB Output isn't correct
7 Incorrect 7 ms 640 KB Output isn't correct
8 Incorrect 7 ms 512 KB Output isn't correct
9 Incorrect 6 ms 512 KB Output isn't correct
10 Incorrect 7 ms 640 KB Output isn't correct