# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
93877 | ahmedie404 | Jetpack (COCI16_jetpack) | C++14 | 85 ms | 66560 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
using namespace std;
int n;
string s;
string ns[11];
bool isfound=false;
bool valid(int x, int y){
return x >= 0 && x < 10 && y >= 0 && y <= n;
}
void DFS(int x, int y, int second, bool isclicked, int startedsecond, string str, int p){
ns[x][y] = 'X';
if(isfound == true) return;
if(y == n){
if(isclicked == 0 && startedsecond == -1){
isfound =true;
int c=0;
for(int i=0;i<str.length();i++)
if(str[i] == ' ')
c++;
cout << c << endl;
cout << str << endl;
}
return;
}
if(valid(x, y+1) && ns[x][y+1] != 'X' && x == 9)
DFS(x, y+1, second+1, false, -1, str, p);
if(valid(x-1, y+1) && ns[x-1][y+1] != 'X')
DFS(x-1, y+1, second+1, true, isclicked == true ? startedsecond : second, str, p);
else
if(x == 0 && ns[x][y+1] != 'X')
DFS(x, y+1, second+1, true, isclicked == true ? startedsecond : second, str, p);
if(valid(x+1, y+1) && ns[x+1][y+1] != 'X'){
if(isclicked)
str = str + to_string(startedsecond) + " " + to_string(second-startedsecond) + "\n";
DFS(x+1, y+1, second+1, false, -1, str, p+1);
}
}
int main(){
cin >> n;
for(int i=0;i<10;i++){
cin >> ns[i];
}
DFS(9, 0, 0, false, 0, "", 0);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |