G++汇编将赢得结束
我一直在尝试用这段代码解决一些问题。在我的机器上,它编译没有错误
g++“文件名.cpp”
但在法官机器上它使用此命令
g++ -g -O2 -std=gnu++17 -static "文件名.cpp"
并且它不会结束编译,因此超出了时间限制。我也使用了这些标志,但它也无法完成编译。
任何可以提供帮助的人。
#include<iostream>
#include<string>
#include<utility>
#include<vector>
#include<queue>
using namespace std;
pair<int,int> maxi;
void bfs(vector<vector<char>> &Adj_List, pair<int,int> start);
int main(){
vector<pair<int,int>> starts;
cin >> maxi.first >> maxi.second;
vector<vector<char>> graph(maxi.first);
char single;
for(int i = 0; i < maxi.first; i++){
for(int j = 0; j < maxi.second; j++){
cin >> single;
graph[i].push_back(single);
if(graph[i][j] == 'V') starts.push_back({i, j});
}}
for(auto k:starts) bfs(graph, k);
for(int i = 0; i < maxi.first; i++){
for(int j = 0; j < maxi.second; j++) cout << graph[i][j] << ' ';
cout << endl;
}
return 0;
}
void bfs(vector<vector<char>> &graph, pair<int,int> start){
queue<pair<int,int>> q;
q.push({start.first, start.second});
while(!q.empty()){
pair<int,int> temp = q.front();
q.pop();
graph[temp.first][temp.second] = 'V';
if(temp.first != maxi.first-1)
if(graph[temp.first+1][temp.second] != '#') q.push({temp.first+1,temp.second});
else{
if(temp.second != maxi.second-1 && graph[temp.first][temp.second+1] != '#' && graph[temp.first][temp.second+1] != 'V')
q.push({temp.first,temp.second+1});
if(temp.second != 0 && graph[temp.first][temp.second-1] != '#' && graph[temp.first][temp.second-1] != 'V')
q.push({temp.first,temp.second-1});
}
}
}
I've been trying solve some problem with this code. In my machine, It compiled with no errors with
g++ "File_name.cpp"
but on the judges machine it uses this command
g++ -g -O2 -std=gnu++17 -static "File_name.cpp"
and it won't end compiling hence Time limit exceeded. I used the those flags too and it won't finish compiling either.
Anyone Who can help.
#include<iostream>
#include<string>
#include<utility>
#include<vector>
#include<queue>
using namespace std;
pair<int,int> maxi;
void bfs(vector<vector<char>> &Adj_List, pair<int,int> start);
int main(){
vector<pair<int,int>> starts;
cin >> maxi.first >> maxi.second;
vector<vector<char>> graph(maxi.first);
char single;
for(int i = 0; i < maxi.first; i++){
for(int j = 0; j < maxi.second; j++){
cin >> single;
graph[i].push_back(single);
if(graph[i][j] == 'V') starts.push_back({i, j});
}}
for(auto k:starts) bfs(graph, k);
for(int i = 0; i < maxi.first; i++){
for(int j = 0; j < maxi.second; j++) cout << graph[i][j] << ' ';
cout << endl;
}
return 0;
}
void bfs(vector<vector<char>> &graph, pair<int,int> start){
queue<pair<int,int>> q;
q.push({start.first, start.second});
while(!q.empty()){
pair<int,int> temp = q.front();
q.pop();
graph[temp.first][temp.second] = 'V';
if(temp.first != maxi.first-1)
if(graph[temp.first+1][temp.second] != '#') q.push({temp.first+1,temp.second});
else{
if(temp.second != maxi.second-1 && graph[temp.first][temp.second+1] != '#' && graph[temp.first][temp.second+1] != 'V')
q.push({temp.first,temp.second+1});
if(temp.second != 0 && graph[temp.first][temp.second-1] != '#' && graph[temp.first][temp.second-1] != 'V')
q.push({temp.first,temp.second-1});
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如@user17732522提到的这个问题是不可重现的。因为问题出在法官那边......而不是上传文件,而是直接将代码复制到站点解决了问题。
as @user17732522 mentioned This problem is not reproducible. because the problem was with the judge side.....rather than uploading the file, copying the code directly to the site fixed the problem.