Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

真坑,,数据弱的吓死人。

Posted by xiang556 at 2019-05-23 18:44:17 on Problem 1075 and last updated at 2019-05-23 18:57:42
评论区的那个代码我hack掉了。

实际上根本就没有0.7可以影响的数据,,居然直接优先队列判成绩高低都能AC,我服了。。

用正解不知道原因疯狂wa,

迷

#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string.h>
#include <limits.h>
#include <string>
#include <iostream>
#include <queue>
#include <math.h>
#include <map>
#include <stack>
#include <set>
#define left (now<<1)
#define right ((now<<1)+1)
#define mid ((l + r) >> 1)
#define midmid ((r + mid) >> 1)
#define LONG_LONG_MIN -9223372036854775808ll
#define LONG_LONG_MAX 9223372036854775807ll
using namespace std;
typedef long long int ll;

const int MAXN = 160;

struct s1{
    int id,loc,grade,nowf;
};

struct cmp{
    bool operator()(s1 x,s1 y){
        if((x.loc == x.nowf && y.loc == y.nowf) || (x.loc != x.nowf && y.loc != y.nowf)){
            return x.grade > y.grade;
        }
        int xx = x.loc == x.nowf ? x.grade * 10 : x.grade * 7;
        int yy = y.loc == y.nowf ? y.grade * 10 : y.grade * 7;
        if(xx != yy){
            return xx > yy;
        }
        return x.loc == x.nowf;
    }
};

int boyRankList[MAXN][MAXN],r[MAXN];
int boyMatch[MAXN],num[MAXN];
priority_queue<s1,vector<s1>,cmp> girlMatch[MAXN];
int manpos[MAXN],limit[MAXN];
queue<int> q;
s1 a[MAXN];
int n,m,t;

void findMatch(){
    while(!q.empty()){ q.pop();}
    for(int i = 1; i <= n; ++i){
        q.push(i); boyMatch[i] = -1; manpos[i] = 0;
    }
    for(int i = 1; i <= m; ++i){
        while(!girlMatch[i].empty()){
            girlMatch[i].pop();
        }
    }
    while(!q.empty()){
        int s = q.size();
        for(int i = 1; i <= s; ++i){
            int now = q.front(); q.pop();
            ++manpos[now];
            if(manpos[now] > num[now]){
                continue;
            }
            int wanna = boyRankList[now][manpos[now]];
            if(girlMatch[wanna].size() < limit[wanna]){
                s1 x; x.id = now; x.grade = a[now].grade;
                x.loc = a[now].loc; x.nowf = r[wanna];
                girlMatch[wanna].push(x);
                boyMatch[now] = wanna;
            }else{
                if(limit[wanna] > 0){
                    s1 y = girlMatch[wanna].top();
                    s1 x; x.id = now; x.grade = a[now].grade;
                    x.loc = a[now].loc; x.nowf = r[wanna];
                    if(x.grade > y.grade){
                        girlMatch[wanna].pop();
                        girlMatch[wanna].push(x);
                        boyMatch[now] = wanna;
                        boyMatch[y.id] = -1;
                        q.push(y.id);
                    }else{
                        q.push(now);
                    }
                }else{
                    q.push(now);
                }
            }
        }
    }
}

int main(){
    scanf("%d",&t);
    while(t--){
        scanf("%d%d",&n,&m);
        for(int i = 1; i <= n; ++i){
            scanf("%d%d",&a[i].loc,&a[i].grade); a[i].id = i;
            scanf("%d",&num[i]);
            for(int j = 1; j <= num[i]; ++j){
                scanf("%d",&boyRankList[i][j]);
            }
        }
        for(int i = 1; i <= m; ++i){
            scanf("%d%d",&r[i],&limit[i]);
        }
        findMatch();
        for(int i = 1; i <= n; ++i){
            if(boyMatch[i] == -1){
                printf("not accepted\n");
            }else{
                printf("%d\n",boyMatch[i]);
            }
        }
        printf("\n");
    }
    return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator