Submission #226788

# Submission time Handle Problem Language Result Execution time Memory
226788 2020-04-25T10:35:31 Z MKopchev Hamburg Steak (JOI20_hamburg) C++14
21 / 100
3000 ms 7028 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 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);
    }

    vector<int> correct={},wrong={};
    for(int i=1;i<=n;i++)wrong.push_back(i);

    while(1)
    {
        vector<int> order={};

        shuffle(wrong.begin(),wrong.end(),rng);

        for(auto p:wrong)order.push_back(p);
        for(auto p:correct)order.push_back(p);

        wrong={};
        correct={};

        //for(auto w:order)cout<<w<<" ";cout<<endl;

        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(auto i:order)
        {
            bool choose=0;
            for(int j=1;j<=k;j++)
            {
                int x1=max(inp[i].x1,outp[j].x1);
                int y1=max(inp[i].y1,outp[j].y1);

                int x2=min(inp[i].x2,outp[j].x2);
                int y2=min(inp[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;

                    correct.push_back(i);

                    break;
                }
            }

            if(choose==0){wrong.push_back(i);ok=0;}
        }

        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:20:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   20 |     scanf("%i%i",&n,&k);
      |     ~~~~~^~~~~~~~~~~~~~
hamburg.cpp:23:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   23 |         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 3 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 2 ms 416 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 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 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 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 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 3 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 3 ms 384 KB Output is correct
22 Correct 2 ms 384 KB Output is correct
23 Correct 3 ms 384 KB Output is correct
24 Correct 2 ms 384 KB Output is correct
25 Correct 2 ms 384 KB Output is correct
26 Correct 2 ms 384 KB Output is correct
27 Correct 2 ms 384 KB Output is correct
28 Correct 2 ms 384 KB Output is correct
29 Correct 2 ms 384 KB Output is correct
30 Correct 2 ms 384 KB Output is correct
31 Correct 3 ms 384 KB Output is correct
32 Correct 2 ms 384 KB Output is correct
33 Correct 4 ms 384 KB Output is correct
34 Correct 3 ms 384 KB Output is correct
35 Correct 3 ms 384 KB Output is correct
36 Correct 2 ms 384 KB Output is correct
37 Correct 3 ms 384 KB Output is correct
38 Correct 2 ms 384 KB Output is correct
39 Correct 3 ms 384 KB Output is correct
40 Correct 2 ms 384 KB Output is correct
41 Correct 3 ms 384 KB Output is correct
42 Correct 2 ms 384 KB Output is correct
43 Correct 3 ms 384 KB Output is correct
44 Correct 3 ms 384 KB Output is correct
45 Correct 4 ms 384 KB Output is correct
46 Correct 2 ms 384 KB Output is correct
47 Correct 3 ms 384 KB Output is correct
48 Correct 3 ms 384 KB Output is correct
49 Correct 2 ms 384 KB Output is correct
50 Correct 3 ms 384 KB Output is correct
51 Correct 2 ms 384 KB Output is correct
52 Correct 2 ms 384 KB Output is correct
53 Correct 2 ms 384 KB Output is correct
54 Correct 3 ms 416 KB Output is correct
55 Correct 2 ms 384 KB Output is correct
56 Correct 2 ms 384 KB Output is correct
57 Correct 2 ms 384 KB Output is correct
58 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 3 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 145 ms 6584 KB Output is correct
6 Correct 147 ms 6512 KB Output is correct
7 Correct 150 ms 6508 KB Output is correct
8 Correct 153 ms 6636 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 416 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 169 ms 6876 KB Output is correct
6 Correct 155 ms 6876 KB Output is correct
7 Correct 154 ms 6876 KB Output is correct
8 Correct 162 ms 6788 KB Output is correct
# 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 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 159 ms 6876 KB Output is correct
14 Correct 153 ms 6860 KB Output is correct
15 Correct 153 ms 6880 KB Output is correct
16 Correct 167 ms 6880 KB Output is correct
17 Correct 166 ms 6876 KB Output is correct
18 Correct 165 ms 6880 KB Output is correct
19 Correct 186 ms 6956 KB Output is correct
20 Correct 169 ms 6876 KB Output is correct
21 Correct 158 ms 6876 KB Output is correct
22 Correct 159 ms 6876 KB Output is correct
23 Correct 180 ms 6876 KB Output is correct
24 Correct 172 ms 6888 KB Output is correct
# 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 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 3 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 3 ms 384 KB Output is correct
22 Correct 2 ms 384 KB Output is correct
23 Correct 3 ms 384 KB Output is correct
24 Correct 2 ms 384 KB Output is correct
25 Correct 2 ms 384 KB Output is correct
26 Correct 2 ms 384 KB Output is correct
27 Correct 2 ms 384 KB Output is correct
28 Correct 2 ms 384 KB Output is correct
29 Correct 2 ms 384 KB Output is correct
30 Correct 2 ms 384 KB Output is correct
31 Correct 3 ms 384 KB Output is correct
32 Correct 2 ms 384 KB Output is correct
33 Correct 4 ms 384 KB Output is correct
34 Correct 3 ms 384 KB Output is correct
35 Correct 3 ms 384 KB Output is correct
36 Correct 2 ms 384 KB Output is correct
37 Correct 3 ms 384 KB Output is correct
38 Correct 2 ms 384 KB Output is correct
39 Correct 3 ms 384 KB Output is correct
40 Correct 2 ms 384 KB Output is correct
41 Correct 3 ms 384 KB Output is correct
42 Correct 2 ms 384 KB Output is correct
43 Correct 3 ms 384 KB Output is correct
44 Correct 3 ms 384 KB Output is correct
45 Correct 4 ms 384 KB Output is correct
46 Correct 2 ms 384 KB Output is correct
47 Correct 3 ms 384 KB Output is correct
48 Correct 3 ms 384 KB Output is correct
49 Correct 2 ms 384 KB Output is correct
50 Correct 3 ms 384 KB Output is correct
51 Correct 2 ms 384 KB Output is correct
52 Correct 2 ms 384 KB Output is correct
53 Correct 2 ms 384 KB Output is correct
54 Correct 3 ms 416 KB Output is correct
55 Correct 2 ms 384 KB Output is correct
56 Correct 2 ms 384 KB Output is correct
57 Correct 2 ms 384 KB Output is correct
58 Correct 2 ms 384 KB Output is correct
59 Correct 213 ms 7000 KB Output is correct
60 Correct 181 ms 6852 KB Output is correct
61 Correct 190 ms 6920 KB Output is correct
62 Correct 160 ms 6876 KB Output is correct
63 Correct 156 ms 6812 KB Output is correct
64 Correct 151 ms 6824 KB Output is correct
65 Correct 172 ms 6852 KB Output is correct
66 Correct 209 ms 6956 KB Output is correct
67 Correct 173 ms 6876 KB Output is correct
68 Correct 162 ms 6860 KB Output is correct
69 Correct 163 ms 6860 KB Output is correct
70 Correct 210 ms 6856 KB Output is correct
71 Correct 200 ms 6872 KB Output is correct
72 Correct 161 ms 6884 KB Output is correct
73 Correct 179 ms 6932 KB Output is correct
74 Correct 175 ms 6868 KB Output is correct
75 Correct 155 ms 6876 KB Output is correct
76 Correct 185 ms 6876 KB Output is correct
77 Correct 181 ms 6876 KB Output is correct
78 Correct 206 ms 6916 KB Output is correct
79 Correct 163 ms 6876 KB Output is correct
80 Correct 155 ms 6872 KB Output is correct
81 Correct 214 ms 6824 KB Output is correct
82 Correct 171 ms 6860 KB Output is correct
83 Correct 163 ms 6876 KB Output is correct
84 Correct 180 ms 6876 KB Output is correct
85 Correct 217 ms 6916 KB Output is correct
86 Correct 171 ms 6924 KB Output is correct
87 Correct 184 ms 6876 KB Output is correct
88 Correct 185 ms 6852 KB Output is correct
89 Correct 178 ms 6860 KB Output is correct
90 Correct 194 ms 6836 KB Output is correct
91 Correct 213 ms 7028 KB Output is correct
92 Correct 198 ms 6860 KB Output is correct
93 Correct 180 ms 6888 KB Output is correct
94 Correct 155 ms 6868 KB Output is correct
95 Correct 193 ms 6960 KB Output is correct
96 Correct 173 ms 6872 KB Output is correct
97 Correct 174 ms 6876 KB Output is correct
98 Correct 153 ms 6832 KB Output is correct
99 Correct 168 ms 6848 KB Output is correct
100 Correct 196 ms 6876 KB Output is correct
101 Correct 221 ms 6856 KB Output is correct
102 Correct 168 ms 6876 KB Output is correct
103 Correct 162 ms 6876 KB Output is correct
104 Correct 164 ms 6876 KB Output is correct
105 Correct 184 ms 6892 KB Output is correct
106 Correct 197 ms 6896 KB Output is correct
107 Correct 175 ms 6872 KB Output is correct
108 Correct 173 ms 6912 KB Output is correct
109 Correct 170 ms 6872 KB Output is correct
110 Correct 229 ms 6848 KB Output is correct
111 Correct 171 ms 6836 KB Output is correct
112 Correct 155 ms 6872 KB Output is correct
113 Correct 191 ms 6872 KB Output is correct
114 Correct 174 ms 6856 KB Output is correct
115 Correct 165 ms 6832 KB Output is correct
116 Correct 172 ms 6928 KB Output is correct
117 Execution timed out 3073 ms 6996 KB Time limit exceeded
118 Halted 0 ms 0 KB -