Submission #229746

# Submission time Handle Problem Language Result Execution time Memory
229746 2020-05-06T09:19:02 Z Vimmer Konstrukcija (COCI20_konstrukcija) C++14
15 / 110
6 ms 384 KB
#include <bits/stdc++.h>

//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("fast-math")
//#pragma GCC optimize("no-stack-protector")

#define F first
#define S second
#define sz(x) ll(x.size())
#define pb push_back
#define N 75005
#define M ll(1e9 + 7)


using namespace std;

typedef long double ld;
typedef long long ll;
typedef short int si;






int main()
{
    ios_base::sync_with_stdio(0); istream::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    ll k;

    cin >> k;

    if (k > 0)
    {
        for (ll i = 1; i <= 1000; i++)
            for (ll j = i; j <= 1000; j++)
            {
                if (i * j + i > 1000 || i + j + 2 > 1000) break;

                for (ll u = 1; u <= 1000; u++)
                {
                    if (i * j + i + u + u * j > 1000 || i + j + u + 2 > 1000) break;

                    ll m = i * j + i + u + u * j, n = i + j + u + 2;

                    ll ans = -1 + i + j + u - i * j - j * u - i * u + i * j * u;

                    if (ans == k)
                    {
                        cout << n << " " << m << endl;

                        int id = 2;

                        for (int u = 1; u <= i; u++) cout << 1 << " " << id++ << endl;

                        for (int b = 1; b <= j; b++)
                        {
                            for (int a = 1; a <= i; a++) cout << a + 1 << " " << id << endl;

                            id++;
                        }

                        for (int c = 1; c <= u; c++)
                          {
                              for (int b = 1; b <= j; b++) cout << b + i + 1 << " " << id << endl;

                              id++;
                          }

                       for (int c = 1; c <= u; c++) cout << i + j + 1 + c << " " << id << endl;

                       exit(0);
                    }
                }
            }
    }
    else
    {
        for (ll i = 1; i <= 1000; i++)
            for (ll j = 1; j <= 1000; j++)
            {
                if (i * j + j + i > 1000) continue;

                ll m = i * j + j + i, n = i + j + 2;

                ll kr = k + 1 - i - j;

                if (i * j == -kr)
                {
                    cout << n << " " << m << endl;

                    int id = 2;

                    for (int u = 1; u <= i; u++) cout << 1 << " " << id++ << endl;

                    vector <int> gr; gr.clear();

                    for (int b = 1; b <= j; b++)
                    {
                        for (int a = 1; a <= i; a++) cout << a + 1 << " " << id << endl;

                        gr.pb(id);

                        id++;
                    }

                    for (auto it : gr) cout << it << " " << id << endl;

                    exit(0);
                }
            }
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Correct.
2 Correct 6 ms 384 KB Correct.
3 Correct 6 ms 384 KB Correct.
4 Correct 6 ms 384 KB Correct.
5 Correct 6 ms 384 KB Correct.
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -