Submission #150258

# Submission time Handle Problem Language Result Execution time Memory
150258 2019-09-01T08:00:12 Z 20190901(#3597, tongnamuu, jf297, upple1) Crosses on the Grid (FXCUP4_cross) C++17
0 / 100
203 ms 8424 KB
#include "cross.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
pair<int, int> arr[200005];
ll it[200005], ot[200005];
int n;
const ll INF=0x3f3f3f3f3f3f3f3fLL;
ll update(ll st[], int idx, ll v, int p, int x, int y)
{
    if(idx<x || idx>y) return st[p];
    if(x==y) return st[p]=v;
    int mid=x+y>>1;
    return st[p]=min(update(st, idx, v, p<<1, x, mid), update(st, idx, v, (p<<1)+1, mid+1, y));
}

long long SelectCross(int K, std::vector<int> I, std::vector<int> O)
{
    n=I.size();
	memset(it, 0x3f, sizeof(it));
	memset(ot, 0x3f, sizeof(ot));
    for(int i=0; i<n; i++)
    {
        arr[i]={O[i], I[i]};
    }

    sort(arr, arr+n);
    for(int i=0; i<K; i++)
    {
        update(ot, i, arr[i].first, 1, 0, n);
        update(it, i, arr[i].second, 1, 0, n);
    }

    ll ans=0;
    for(int i=0; i<n; i++)
    {
        ll isize=it[1], osize=ot[1];
        ans=max(ans, osize*osize-(osize-isize)*(osize-isize));
		// cout<<ans<<' ';
        update(ot, i, INF, 1, 0, n);
        update(it, i, INF, 1, 0, n);
        update(ot, (i+K)%n, arr[(i+K)%n].first, 1, 0, n);
        update(it, (i+K)%n, arr[(i+K)%n].second, 1, 0, n);
    }

	return ans;
}

Compilation message

cross.cpp: In function 'll update(ll*, int, ll, int, int, int)':
cross.cpp:13:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
     int mid=x+y>>1;
             ~^~
# Verdict Execution time Memory Grader output
1 Correct 7 ms 3584 KB Output is correct
2 Correct 7 ms 3456 KB Output is correct
3 Correct 8 ms 3584 KB Output is correct
4 Correct 8 ms 3584 KB Output is correct
5 Correct 27 ms 3840 KB Output is correct
6 Runtime error 203 ms 8424 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 3584 KB Output is correct
2 Correct 7 ms 3456 KB Output is correct
3 Correct 8 ms 3584 KB Output is correct
4 Correct 8 ms 3584 KB Output is correct
5 Correct 27 ms 3840 KB Output is correct
6 Runtime error 203 ms 8424 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 3584 KB Output is correct
2 Correct 7 ms 3456 KB Output is correct
3 Correct 8 ms 3584 KB Output is correct
4 Correct 8 ms 3584 KB Output is correct
5 Correct 27 ms 3840 KB Output is correct
6 Runtime error 203 ms 8424 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Halted 0 ms 0 KB -