QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#381447#5513. Advertisement 2stegatxins0#Compile Error//C++202.4kb2024-04-07 17:51:202024-07-04 03:33:46

Judging History

你现在查看的是最新测评结果

  • [2024-07-04 03:33:46]
  • 评测
  • [2024-04-07 17:51:20]
  • 提交

answer

//  {{{

#include <bits/stdc++.h>
using namespace std;

#ifndef ONLINE_JUDGE
#include "debug.cpp"
#else
#define debug(...)
#define debugArr(...)
#endif

using ll = long long;

const int inf = 1073741823;
const ll infl = 1LL << 60;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#define rep(i, b) for (auto i = 0; i < (b); i++)
#define reps(i, b) for (auto i = 1; i <= (b); i++)

// }}}


const int mxN = 500001;
int n,ans,curx,cure;
bool visited[mxN];
bool influ[mxN][mxN];

struct node{
    int x,e;
}re[mxN];

bool cmp(const node a, const node b){
    return a.e > b.e;
}

int main() {
    scanf("%d",&n);
    bool subtask1=1;
    memset(visited,0,sizeof(visited));
    memset(influ,0,sizeof(influ));
    for(int i=1; i<=n; i++){
        scanf("%d%d",&re[i].x,&re[i].e);
        if(i>1 && re[i].e != re[i-1].e)subtask1=0;
    }
    if(subtask1){
        set<int> ss;
        for(int i=1; i<=n; i++){
            ss.insert(re[i].x);
        }
        printf("%d",(int)ss.size());
        return 0;
    }
    //sort(re+1, re+n+1, cmp);

    for(int i=1; i<=n; i++){
        curx = re[i].x;
        cure = re[i].e;
        for(int j=1; j<=n; j++){
            if(cure - re[j].e >= abs(curx - re[j].x))influ[i][j] = 1;
        }
    }
    bool allclear=0;
    //for(int i=1; i<=n; i++){
        //allclear = 1;
        //for(int j=1; j<=n; j++){
            //for(int j=1; j<=n; j++){
            //}
            ////visited[j] |= influ[i][j];
            //if(!visited[j] && influ[i][j])a
            //if(!visited[j])allclear=0;
        //}
    //}
    int ans=0;
    bool alrput[mxN];
    memset(alrput,0,sizeof(alrput));
    while(true){
        int curmax=0,curidx=0;
        for(int i=1; i<=n; i++){
            if(alrput[i])continue;
            int cur=0;
            for(int j=1; j<=n; j++){
                if(!visited[j] && influ[i][j])cur++;
            }
            if(cur > curmax){curmax = cur; curidx=i;}
        }
        alrput[curidx]=1;
        allclear=1;
        for(int j=1; j<=n; j++){
            visited[j] |= influ[curidx][j];
            if(!visited[j])allclear=0;
        }
        ans++;
        if(allclear)break;
    }
    //debug(ans);
    printf("%d",ans);
}


// biggest problem here is dat u can still donate to the one alr visited

// subtask 1, since all e is equal, just count the number of unique coordinates

詳細信息

answer.code: In function ‘int main()’:
answer.code:41:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   41 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
answer.code:46:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   46 |         scanf("%d%d",&re[i].x,&re[i].e);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/cchHJ85c.o: in function `main':
answer.code:(.text.startup+0x31): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cchHJ85c.o
answer.code:(.text.startup+0x3f): relocation truncated to fit: R_X86_64_PC32 against symbol `visited' defined in .bss section in /tmp/cchHJ85c.o
answer.code:(.text.startup+0x84): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cchHJ85c.o
answer.code:(.text.startup+0xe8): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cchHJ85c.o
answer.code:(.text.startup+0x17c): relocation truncated to fit: R_X86_64_PC32 against symbol `cure' defined in .bss section in /tmp/cchHJ85c.o
answer.code:(.text.startup+0x182): relocation truncated to fit: R_X86_64_PC32 against symbol `curx' defined in .bss section in /tmp/cchHJ85c.o
answer.code:(.text.startup+0x1ad): relocation truncated to fit: R_X86_64_PC32 against symbol `visited' defined in .bss section in /tmp/cchHJ85c.o
answer.code:(.text.startup+0x251): relocation truncated to fit: R_X86_64_PC32 against symbol `visited' defined in .bss section in /tmp/cchHJ85c.o
answer.code:(.text.startup+0x2ab): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cchHJ85c.o
answer.code:(.text.startup+0x35e): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cchHJ85c.o
collect2: error: ld returned 1 exit status