Submission #154330

# Submission time Handle Problem Language Result Execution time Memory
154330 2019-09-20T18:37:18 Z dandrozavr Chessboard (IZhO18_chessboard) C++14
0 / 100
700 ms 1072 KB
#include <bits/stdc++.h>
#define fi first
#define se second
#define ld long double
#define pi 3.1415926535897932384626433832795
#define sz(a) (int)a.size()
#define pii pair < int , int >
#define IOS {ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0);}
#define TIME 1.0*clock()/CLOCKS_PER_SEC
#define pb push_back
using namespace std;
mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count());
const int tinf = (int)1e9 + 7;
const long long inf = (long long)1e18 + 7;
const int N = 2e5 + 5;
const int M = 1e9 + 7;
int a[505][505];


namespace fastio {
    template <class T> ostream &operator<<(ostream &os, const vector<T> &container){for (auto &u : container)os << u << " ";return os;}
    template<class T1, class T2> ostream& operator << (ostream& os, const pair<T1, T2>& p) { return os << p.first << " " << p.second; }
    template <class T> ostream &operator<<(ostream &os, set<T> const& con) { for (auto &u : con) os << u << " "; return os; }
    void pr() {}
    template <typename T, typename... args> void pr(T x, args... tail) { cout << x << " "; pr(tail...);}
}
using namespace fastio;



signed main(){
    freopen("input.txt", "w", stdout);

    int n = gen() % 400 + 50;

    cout << n << " ";

    vector < pair < pii , pii > > all;

    int k = 200;
    for (int i = 0; i < k; ++i)
    {
        while(clock() <= 0.7 * CLOCKS_PER_SEC)
        {
            int x1 = gen() % n ;
            int x2 = gen() % n ;
            if (x1 > x2)
                swap(x1, x2);
            int y1 = gen() % n;
            int y2 = gen() % n;
            if (y1 > y2)
                swap(y1, y2);
            bool g = 1;

            for (int i = x1; i <= x2; ++i)
                for (int j = y1; j <= y2; ++j)
                  if (a[i][j])
                {
                    g = 0;
                    break;
                }
            if (g)
            {
                all.pb({{x1, y1}, {x2, y2}});
                break;
            }
        }
        if (all.size())
        {
            auto la = all.back();
            for (int i = la.fi.fi; i <= la.se.fi; ++i)
                for (int j = la.fi.se; j <= la.se.se; ++j)
                  a[i][j] = 1;
        }
    }

    cout << all.size()<<endl;
    for (auto i : all)
        cout<<i.fi.fi+1<<" "<<i.fi.se+1<<" "<<i.se.fi+1<<" "<<i.se.se+1<<endl;

}

Compilation message

chessboard.cpp: In function 'int main()':
chessboard.cpp:32:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     freopen("input.txt", "w", stdout);
     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 700 ms 568 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 190 ms 704 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 181 ms 1072 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 181 ms 1072 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 190 ms 704 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 700 ms 568 KB Output isn't correct
2 Halted 0 ms 0 KB -