Submission #149438

# Submission time Handle Problem Language Result Execution time Memory
149438 2019-09-01T06:29:21 Z Solo Leveling (#3786, wzy) Crosses on the Grid (FXCUP4_cross) C++17
0 / 100
5 ms 384 KB
#include "cross.h"
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define F first
#define S second

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
// order_of_key
typedef tree<
pair<int, int>,
null_type,
less<pair<int, int>>,
rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
ordered_set X;

long long SelectCross(int K, std::vector<int> I, std::vector<int> O) {
#define int long long
	vector<pii> v(I.size());
	for(int i = 0 ; i < I.size() ; i ++){
		v.push_back(pii(O[i] , I[i]));
	}
	sort(v.rbegin() , v.rend());
	long long ans = 0;
	for(int i = 0 ; i < I.size() ; i ++){
		if(X.size() >= K - 1){
			pii R = *X.find_by_order(K-2);
			R.first *= -1;
			R.first = min(R.first , v[i].second);
			// cout<<v[i].first * v[i].first<<" " << -2*(v[i].first - R.first) << endl;
			ans = max(ans ,v[i].first * v[i].first - 2*(v[i].first - R.first));
		}
		// cout<<v[i].first<<" "<<v[i].second<<endl;
		X.insert(pii(-v[i].second, i));
	}
#undef int 
	return ans;
}

Compilation message

cross.cpp: In function 'long long int SelectCross(int, std::vector<int>, std::vector<int>)':
cross.cpp:25:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0 ; i < I.size() ; i ++){
                  ~~^~~~~~~~~~
cross.cpp:30:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0 ; i < I.size() ; i ++){
                  ~~^~~~~~~~~~
cross.cpp:31:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(X.size() >= K - 1){
      ~~~~~~~~~^~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -