Submission #149869

# Submission time Handle Problem Language Result Execution time Memory
149869 2019-09-01T07:18:32 Z ProofByTLE(#3614, Mahotsukai, McDic, Redux) On the Grid (FXCUP4_grid) C++17
43 / 100
39 ms 464 KB
#include<bits/stdc++.h>
#include<chrono>
#include<random>
using namespace std;
using namespace chrono;
#define all(a) a.begin(), a.end()
#define sz(x) (int(x.size()))
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef vector<string> vs;
template<class T1, class T2>
istream &operator>>(istream &in, pair<T1, T2> &P){
	in >> P.first >> P.second;
	return in;
}
template<class T1, class T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &P){
	out << "(" << P.first << ", " << P.second << ")";
	return out;
}
template<class T>
istream &operator>>(istream &in, vector<T> &arr){
	for(auto &x: arr) in >> x;
	return in;
}
template<class T>
ostream &operator<<(ostream &out, const vector<T> &arr){
	for(auto &x: arr) out << x << ' '; cout << "\n";
	return out;
}
template<class T>
istream &operator>>(istream &in, deque<T> &arr){
	for(auto &x: arr) in >> x;
	return in;
}
template<class T>
ostream &operator<<(ostream &out, const deque<T> &arr){
	for(auto &x: arr) out << x << ' '; cout << "\n";
	return out;
}
#include"grid.h"

int query(int n, vector<pii> &g){
	vi v(n);
	for(int i = 0; i < n; i ++) v[i] = g[i].second;
	int k = PutDisks(v) - n;
	for(int i = 0; i < n - k; i ++){
		g[i].first = min(g[i].first, k + i + 1);
	}
	return k;
}

vector<int> SortDisks(int n){
	vector<pii> g(n);
	random_device rd;
	mt19937 f(rd());
	for(int i = 0; i < n; i ++) g[i] = {n + 1, i};
	while(query(n, g) > 0){
		sort(all(g), [&](pii x, pii y){
			if(y.first == n + 1){
				return false;
			}
			if(x.first == n + 1){
				return true;
			}
			return x.first < y.first;
		});
		for(int i = n - 1; i > 0 && g[i].first != n + 1; i --){
			if(g[i - 1].first == g[i].first){
				shuffle(g.begin(), g.begin() + i + 1, f);
				break;
			}
		}
	}
	vi res(n);
	for(int i = 0; i < n; i ++){
		res[g[i].second] = i + 1;
	}
	return res;
}
/*
30
30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
30
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
*/

//////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                                  //
//                                                                                                  //
//                                              _____________                                       //
//             ++++++++++                ___------------------\\\\                                  //
//           +++`+``+`+`++++        ///`````````````````````````````\\\                             //
//           ++`+`+``+++`++++  /////```````````````````````````````````\\                           //
//           +++`++`+`+``+++/////`````````````````````````````````````````\\                        //
//             +++`++`+``+///```````````|```````````````````````````````````\\                      //
//          ____++++/++++/`````````````/````````|````````|```````````````````\\                     //
//        /  /  / |    //``````````````|````````|```````|````````|````````````\\                    //
//       /  /  /  | ///````````/```````|```````||```````|````````|``````\```````\\                  //
//       | /  /   |///`````````|``````/````````|````````|````````|```````|```````\\                 //
//       |/   |   |//``|```````|``````|````````|`````````|```````|```````|````````\\                //
//       /\___|__//`|``|```````|`    |      ``:|````````|:```````|```````|```|`````|                //
//      /     /  /``|``|``````|/     |        :|     ```:|```````|```````|``++````++                //
//     /     / //```|``|``````|      |        |:        :|    ```|```````|```++``++`\               //
//     |    /  /````|``|``````/    _.::::.    |          |      |    ````|```|`++`\`|               //
//     |   /   |````|``|`````|            `                    |       ``|```++``++`|               //
//     |  /    |````|``|`````|                                 :         |``++````++|               //
//     | /     /````|``|`````|                              _.-:::.      |..`|``.`|.|               //
//     |/     /`````|``|`````|                                     `     |```|````|`|               //
//    /|      |`````|``|`````|                    :'                    .|```|````|.|               //
//   / |      |`````|``|`````|                                         /|-|``|````|`|               //
//  /  |      |`````|```\````|                                        / ||```|````|``\              //
// /   |      |`````|````|```|::                                    /_| ||```|````|``|              //
//            |`````|````|```|:|:.        `.._                    .\___/:|```|````|``|              //
//            |`````\````|```|:|::-          ``:::....           -:|:|:::|```|````|``|              //
//            |``````|```|```|:|::`|.                          .:::|:|:::|```|````|``|              //
//             \`````|```|```|:|::/|--.                     .`:|:::|:|:::/```|````|``|              //
//              |````|```|```\:|:|:|-----             _..-:|:|:|:::|:|::|````|````|`/               //
//              |````|```|````\|:|:|-------.____.....------|/::|:::|:|::|````|````|`|               //
//              |````|```|\````\:|/\___________    ________/\--\:::|:|::|````/````|`|               //
//              |````\```| \```|:/-------------\  /----------\``\::|:|::|```/`````|`|               //
//              |`````|``|  \``|/---------------\/------------\_________|```|`````|`|               //
//                                                                                                  //
//////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                                  //
//                                        Created by Aeren                                          //
//                                                                                                  //
//////////////////////////////////////////////////////////////////////////////////////////////////////

Compilation message

grid.cpp: In function 'std::ostream& operator<<(std::ostream&, const std::vector<_Tp>&)':
grid.cpp:33:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
  for(auto &x: arr) out << x << ' '; cout << "\n";
  ^~~
grid.cpp:33:37: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  for(auto &x: arr) out << x << ' '; cout << "\n";
                                     ^~~~
grid.cpp: In function 'std::ostream& operator<<(std::ostream&, const std::deque<_Tp>&)':
grid.cpp:43:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
  for(auto &x: arr) out << x << ' '; cout << "\n";
  ^~~
grid.cpp:43:37: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  for(auto &x: arr) out << x << ' '; cout << "\n";
                                     ^~~~
# Verdict Execution time Memory Grader output
1 Correct 6 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
6 Correct 6 ms 384 KB Output is correct
7 Correct 6 ms 384 KB Output is correct
8 Correct 6 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
6 Correct 6 ms 384 KB Output is correct
7 Correct 6 ms 384 KB Output is correct
8 Correct 6 ms 384 KB Output is correct
9 Correct 11 ms 384 KB Output is correct
10 Correct 18 ms 384 KB Output is correct
11 Correct 22 ms 464 KB Output is correct
12 Correct 21 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 22 ms 384 KB Output is correct
15 Correct 22 ms 384 KB Output is correct
16 Correct 20 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 384 KB Output is correct
2 Correct 22 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 22 ms 384 KB Output is correct
5 Correct 18 ms 384 KB Output is correct
6 Correct 6 ms 384 KB Output is correct
7 Correct 20 ms 384 KB Output is correct
8 Correct 6 ms 384 KB Output is correct
9 Correct 11 ms 384 KB Output is correct
10 Incorrect 39 ms 384 KB Output isn't correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 22 ms 464 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 21 ms 384 KB Output is correct
16 Halted 0 ms 0 KB -
17 Correct 6 ms 384 KB Output is correct
18 Correct 6 ms 384 KB Output is correct