Submission #317278

# Submission time Handle Problem Language Result Execution time Memory
317278 2020-10-29T09:31:39 Z fadi57 Pohlepko (COCI16_pohlepko) C++14
10 / 80
454 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 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Runtime error 347 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
4 Runtime error 292 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
5 Runtime error 338 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
6 Runtime error 297 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
7 Runtime error 341 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
8 Runtime error 448 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
9 Runtime error 281 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
10 Runtime error 289 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
11 Runtime error 290 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
12 Runtime error 309 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
13 Runtime error 292 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
14 Runtime error 454 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
15 Runtime error 290 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
16 Runtime error 366 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)