Submission #330225


Source Code Expand

#include<bits/stdc++.h>

using namespace std;

#define dbg(x) cerr << (#x) << " --> " << (x) << endl
#define lli long long int
#define pii pair<int,int>
#define mod 1000000007
#define N (int)1e6+10
#define mp make_pair
#define pb push_back
#define nd second
#define st first
#define endl '\n'
#define inf mod
#define sag (sol|1)
#define sol (root<<1)
#define ort ((bas+son)>>1)

vector< pii > a1,a2;
int x,y,n,m,i,j,k;
int mn = 1000000,ans1,ans2;
int dp[5005][5005];
int H[5005][5005];

bool cmp(pii x,pii y){
    if(x.nd < y.nd)
        return 1;
    return 0;
}

int main(){

    cin >> n >> m;

    for(i=1 ; i<=n ; i++){
        cin >> x >> y;
        a1.pb(mp(x,i));
        a2.pb(mp(y,i));
    }

    sort(a1.begin(),a1.end());
    sort(a2.begin(),a2.end());

    for(i=0 ; i<n ; i++){
        a1[i].st = i+1;
        a2[i].st = i+1;
    }

    sort(a1.begin(),a1.end(),cmp);
    sort(a2.begin(),a2.end(),cmp);

    for(i=0 ; i<n ; i++){
        H[a1[i].st][a2[i].st] = 1;
    }

    for(i=1 ; i<=n ; i++)
        for(j=1 ; j<=n ; j++)
            dp[i][j] = dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1] + H[i][j];

    for(i=0 ; i<n ; i++)
        for(j=0 ; j<n ; j++){
            int x1 = a1[i].st; int y1 = a2[i].st;
            int x2 = a1[j].st; int y2 = a2[j].st;

            if(x1 < x2) swap(x1,x2);
            if(y1 < y2) swap(y1,y2);

            int t = dp[x1][y1] + dp[x2][y2] - dp[x1][y2] - dp[x2][y1] + H[x2][y2];

            if(t>=m and mn>t){
                mn = t;
                ans1 = i+1;
                ans2 = j+1;
            }
        }

    cout << ans1 << ' ' << ans2 << endl;
}

Submission Info

Submission Time
Task 2 - Artemis
User ykaya
Language C++ (G++ 4.6.4)
Score 0
Code Size 1689 Byte
Status WA
Exec Time 1054 ms
Memory 118816 KB

Judge Result

Set Name Set01 Set02 Set03 Set04 Set05 Set06 Set07 Set08 Set09 Set10 Set11 Set12 Set13 Set14 Set15 Set16 Set17 Set18 Set19 Set20
Score / Max Score 0 / 5 0 / 5 0 / 5 0 / 5 0 / 5 0 / 5 0 / 5 0 / 5 0 / 5 0 / 5 0 / 5 0 / 5 0 / 5 0 / 5 0 / 5 0 / 5 0 / 5 0 / 5 0 / 5 0 / 5
Status
WA × 1
WA × 1
WA × 1
WA × 1
WA × 1
WA × 1
MLE × 1
MLE × 1
WA × 1
WA × 1
MLE × 1
MLE × 1
RE × 1
RE × 1
RE × 1
MLE × 1
RE × 1
TLE × 1
TLE × 1
MLE × 1
Set Name Test Cases
Set01 01
Set02 02
Set03 03
Set04 04
Set05 05
Set06 06
Set07 07
Set08 08
Set09 09
Set10 10
Set11 11
Set12 12
Set13 13
Set14 14
Set15 15
Set16 16
Set17 17
Set18 18
Set19 19
Set20 20
Case Name Status Exec Time Memory
01 WA 45 ms 5796 KB
02 WA 31 ms 2464 KB
03 WA 30 ms 2908 KB
04 WA 28 ms 2336 KB
05 WA 46 ms 5724 KB
06 WA 48 ms 6948 KB
07 MLE 673 ms 118308 KB
08 MLE 782 ms 117924 KB
09 WA 76 ms 10652 KB
10 WA 76 ms 10660 KB
11 MLE 340 ms 31520 KB
12 MLE 349 ms 31532 KB
13 RE 312 ms 13868 KB
14 RE 304 ms 1572 KB
15 RE 307 ms 1572 KB
16 MLE 304 ms 32288 KB
17 RE 302 ms 1312 KB
18 TLE 1047 ms 97440 KB
19 TLE 1054 ms 118816 KB
20 MLE 735 ms 118816 KB