Submission #226778

# Submission time Handle Problem Language Result Execution time Memory
226778 2020-04-25T10:20:54 Z MKopchev Hamburg Steak (JOI20_hamburg) C++14
6 / 100
3000 ms 4412 KB
#include<bits/stdc++.h>
using namespace std;
const int nmax=2e5+42;

struct rect
{
    int x1,y1,x2,y2;
};

int n,k;

rect inp[nmax];

rect outp[nmax];

mt19937 rng(42);

int order[nmax];

int main()
{
    scanf("%i%i",&n,&k);
    for(int i=1;i<=n;i++)
    {
        scanf("%i%i%i%i",&inp[i].x1,&inp[i].y1,&inp[i].x2,&inp[i].y2);
    }

    while(1)
    {
        for(int i=1;i<=n;i++)
            order[i]=i;

        shuffle(order+1,order+n+1,rng);

        for(int i=1;i<=k;i++)
        {
            outp[i].x1=1;
            outp[i].y1=1;
            outp[i].x2=1e9;
            outp[i].y2=1e9;
        }

        bool ok=1;

        for(int i=1;i<=n;i++)
        {
            bool choose=0;
            for(int j=1;j<=k;j++)
            {
                int x1=max(inp[order[i]].x1,outp[j].x1);
                int y1=max(inp[order[i]].y1,outp[j].y1);

                int x2=min(inp[order[i]].x2,outp[j].x2);
                int y2=min(inp[order[i]].y2,outp[j].y2);

                if(x1<=x2&&y1<=y2)
                {
                    choose=1;
                    outp[j].x1=x1;
                    outp[j].y1=y1;
                    outp[j].x2=x2;
                    outp[j].y2=y2;
                    break;
                }
            }

            if(choose==0){ok=0;break;}
        }

        if(ok)
        {
            for(int j=1;j<=k;j++)
                printf("%i %i\n",outp[j].x1,outp[j].y1);
            return 0;
        }
    }
    return 0;
}

Compilation message

hamburg.cpp: In function 'int main()':
hamburg.cpp:22:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   22 |     scanf("%i%i",&n,&k);
      |     ~~~~~^~~~~~~~~~~~~~
hamburg.cpp:25:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   25 |         scanf("%i%i%i%i",&inp[i].x1,&inp[i].y1,&inp[i].x2,&inp[i].y2);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 9 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 43 ms 420 KB Output is correct
9 Correct 11 ms 384 KB Output is correct
10 Correct 52 ms 384 KB Output is correct
11 Correct 21 ms 384 KB Output is correct
12 Correct 7 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 2 ms 360 KB Output is correct
6 Correct 3 ms 408 KB Output is correct
7 Correct 371 ms 384 KB Output is correct
8 Correct 22 ms 428 KB Output is correct
9 Correct 64 ms 384 KB Output is correct
10 Correct 305 ms 424 KB Output is correct
11 Correct 71 ms 428 KB Output is correct
12 Correct 12 ms 384 KB Output is correct
13 Correct 129 ms 384 KB Output is correct
14 Correct 343 ms 420 KB Output is correct
15 Correct 17 ms 384 KB Output is correct
16 Correct 464 ms 420 KB Output is correct
17 Correct 368 ms 504 KB Output is correct
18 Correct 680 ms 424 KB Output is correct
19 Correct 92 ms 504 KB Output is correct
20 Execution timed out 3050 ms 384 KB Time limit exceeded
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 152 ms 4336 KB Output is correct
6 Correct 167 ms 4216 KB Output is correct
7 Correct 169 ms 4176 KB Output is correct
8 Correct 141 ms 4216 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 9 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 421 ms 4216 KB Output is correct
6 Execution timed out 3068 ms 4236 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 43 ms 420 KB Output is correct
9 Correct 11 ms 384 KB Output is correct
10 Correct 52 ms 384 KB Output is correct
11 Correct 21 ms 384 KB Output is correct
12 Correct 7 ms 384 KB Output is correct
13 Correct 540 ms 4412 KB Output is correct
14 Correct 635 ms 4300 KB Output is correct
15 Correct 2406 ms 4288 KB Output is correct
16 Execution timed out 3082 ms 4344 KB Time limit exceeded
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 2 ms 360 KB Output is correct
6 Correct 3 ms 408 KB Output is correct
7 Correct 371 ms 384 KB Output is correct
8 Correct 22 ms 428 KB Output is correct
9 Correct 64 ms 384 KB Output is correct
10 Correct 305 ms 424 KB Output is correct
11 Correct 71 ms 428 KB Output is correct
12 Correct 12 ms 384 KB Output is correct
13 Correct 129 ms 384 KB Output is correct
14 Correct 343 ms 420 KB Output is correct
15 Correct 17 ms 384 KB Output is correct
16 Correct 464 ms 420 KB Output is correct
17 Correct 368 ms 504 KB Output is correct
18 Correct 680 ms 424 KB Output is correct
19 Correct 92 ms 504 KB Output is correct
20 Execution timed out 3050 ms 384 KB Time limit exceeded
21 Halted 0 ms 0 KB -