Submission #317281

# Submission time Handle Problem Language Result Execution time Memory
317281 2020-10-29T09:34:46 Z fadi57 Pohlepko (COCI16_pohlepko) C++14
10 / 80
456 ms 65540 KB
#include <bits/stdc++.h>
using namespace std;
const long long mx=3000;
const long long mod=1e9+7;
typedef long long ll;


queue<pair<string,pair<int,int>>>q;
int n,m;
string a[mx];

int dx[2]={0,1};
int dy[2]={1,0};
string bfs(){
    string z="";
    z+=a[0][0];
    string ans="z";
    for(int i=0;i<n+m;i++){ans+='z';}
    q.push({z,{0,0}});
    while(!q.empty()){
        pair<string,pair<int,int>>qq;
          qq=q.front();
          q.pop();
        int myx=qq.second.first;
        int myy=qq.second.second;
      
        string h=qq.first;
        if(myx==(n-1)&&myy==(m-1)){ans=min(ans,qq.first);}else{
           
        
        for(int i=0;i<2;i++){
            int xx=myx+dx[i];
            int yy=myy+dy[i];
            if(xx<n&&yy<m){
                q.push({h+a[xx][yy],{xx,yy}});
            }
        }}
    }
    return ans;
}


int main() { 
cin>>n>>m;
for(int i=0;i<n;i++){
    cin>>a[i];
    
}
cout<<bfs();

}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Runtime error 356 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
4 Runtime error 299 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
5 Runtime error 342 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
6 Runtime error 301 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
7 Runtime error 344 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
8 Runtime error 456 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
9 Runtime error 299 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
10 Runtime error 293 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
11 Runtime error 300 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
12 Runtime error 307 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
13 Runtime error 306 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
14 Runtime error 453 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
15 Runtime error 295 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
16 Runtime error 355 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)