Submission #93874

#TimeUsernameProblemLanguageResultExecution timeMemory
93874ahmedie404Jetpack (COCI16_jetpack)C++14
48 / 80
1083 ms66560 KiB
#include <iostream> #include <algorithm> 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){ 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)

jetpack.cpp: In function 'void DFS(int, int, int, bool, int, std::__cxx11::string, int)':
jetpack.cpp:24:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(int i=0;i<str.length();i++)
                         ~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...