请问为何出错
  • 板块学术版
  • 楼主lnwwr
  • 当前回复16
  • 已保存回复16
  • 发布时间2020/9/12 21:42
  • 上次更新2023/11/5 13:18:41
查看原帖
请问为何出错
347174
lnwwr楼主2020/9/12 21:42
#include <iostream>
  
#include <queue>
  
using namespace std;
  
bool vis[100005][100005];
  
int workernet[100005][100005];
  
int workernetcnt[100005];
  
int n , m , q;
  
bool BFS(int a , int L);
  
int main() {
  
    cin >> n >> m >> q;
  
    for(int i = 0; i < m; i++) {
                         
        int u , v;
                         
        cin >> u >> v;
  
        workernet[u][workernetcnt[u]] = v;
  
        workernet[v][workernetcnt[v]] = u;
  
        workernetcnt[u]++;
  
        workernetcnt[v]++;
  
    }
  
    for(int i = 0; i < q; i++) {
                         
        int a , L;
                         
        cin >> a >> L;
  
        bool xuanusedflag = BFS(a , L);
  
        if(xuanusedflag) {
  
            cout << "Yes" << endl;
  
            continue;
  
        } else {
  
            cout << "No" << endl;
  
        }
  
    }
  
}
  
bool BFS(int a , int L) {
  
    queue<int>neededworkers;
  
    queue<int>conectedworkerscnt;
  
    neededworkers.push(a);
  
    conectedworkerscnt.push(workernetcnt[a]);
  
    while(!neededworkers.empty()) {
  
        for(int i = 0; i < conectedworkerscnt.front(); i++) {
                                                      
            if(vis[neededworkers.front()][i] == false && 
                                                      neededworkers.front() <= n && i <= n) {
               
                                                                                             neededworkers.push(workernet[neededworkers.front()][i]);
                                                                                             
               
                                                                                             vis[neededworkers.front()][i] = true;
                                                                                             
            }
                                                                                             
        }
                                                                                             
        if(neededworkers.front() == 1 && L == 1) {
                                                                                             
            return true;
                                                                                             
        }
                                                                                             
    }
                                                                                             
    return false;
                                                                                             
}

程序如上,编译数据:

            No valid executable file was produced by the compiler
/usr/bin/ld: ./ccZWVxUp.o: in function `main':
src:(.text+0xb): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in ./ccZWVxUp.o
/usr/bin/ld: src:(.text+0x1e): relocation truncated to fit: R_X86_64_PC32 against symbol 

`m' defined in .bss section in ./ccZWVxUp.o
/usr/bin/ld: src:(.text+0x2d): relocation truncated to fit: R_X86_64_PC32 against symbol 

`q' defined in .bss section in ./ccZWVxUp.o
/usr/bin/ld: src:(.text+0x42): relocation truncated to fit: R_X86_64_PC32 against symbol 

`m' defined in .bss section in ./ccZWVxUp.o
/usr/bin/ld: src:(.text+0x87): relocation truncated to fit: R_X86_64_PC32 against symbol `workernetcnt' defined in .bss section in ./ccZWVxUp.o

/usr/bin/ld: src:(.text+0xac): relocation truncated to fit: R_X86_64_PC32 against symbol `workernet' defined in .bss section in ./ccZWVxUp.o

/usr/bin/ld: src:(.text+0xc6): relocation truncated to fit: R_X86_64_PC32 against symbol `workernetcnt' defined in .bss section in ./ccZWVxUp.o

/usr/bin/ld: src:(.text+0xeb): relocation truncated to fit: R_X86_64_PC32 against symbol `workernet' defined in .bss section in ./ccZWVxUp.o

/usr/bin/ld: src:(.text+0x103): relocation truncated to fit: R_X86_64_PC32 against symbol `workernetcnt' defined in .bss section in ./ccZWVxUp.o

/usr/bin/ld: src:(.text+0x11a): relocation truncated to fit: R_X86_64_PC32 against symbol `workernetcnt' defined in .bss section in ./ccZWVxUp.o

/usr/bin/ld: src:(.text+0x132):  从输出所省略的额外重寻址溢出

collect2: 错误:ld 返回 1

2020/9/12 21:42
加载中...