Go to diff to previous submission
#define PROJECT 4 #include <iostream> #include <algorithm> #include <vector> #include <queue> #include <limits> typedef unsigned long long ull; using namespace std; #if PROJECT == 1 int main() { int l, a; while (cin >> l >> a) { int pos; char dir; cin >> pos >> dir; } } #elif PROJECT == 2 #elif PROJECT == 3 #elif PROJECT == 4 int main() { int r, s, gr, gs, lr, ls; int grid[105][105]; //inicializovat este! vector< pair<int,int> > moves; moves.push_back(make_pair(1,2)); moves.push_back(make_pair(1,-2)); moves.push_back(make_pair(-1,2)); moves.push_back(make_pair(-1,-2)); moves.push_back(make_pair(2,1)); moves.push_back(make_pair(2,-1)); moves.push_back(make_pair(-2,1)); moves.push_back(make_pair(-2,-1)); queue< pair<int,int> > todo; while(cin >> r >> s >> gr >> gs >> lr >> ls) { for (int i=0; i<103; i++) for (int j=0; j<103; j++) grid[i][j]=-1; pair<int,int> leaf = make_pair(lr,ls); todo.push(make_pair(gr,gs)); grid[gr][gs]=0; while(!todo.empty()){ pair<int,int> current = todo.front(); todo.pop(); /*for (int i=1; i<=r; i++) { for (int j=1; j<=s; j++) cout << " " << grid[i][j]; cout << endl; }*/ for(vector< pair<int,int> >::iterator i = moves.begin(); i!=moves.end();i++) { pair<int,int> next = make_pair(current.first+i->first,current.second+i->second); if(next.first >= 1 && next.first <= r && next.second >= 1 && next.second <= s){ if(grid[next.first][next.second]==-1) { grid[next.first][next.second]=grid[current.first][current.second]+1; todo.push(next); } } } //cout << endl << "/////////////////////////////" << endl; } if(grid[leaf.first][leaf.second]==-1) cout << "impossible" << endl; else { cout << grid[leaf.first][leaf.second] << endl; } //1==1; } } #elif PROJECT == 5 int main() { int n,m; while (cin >> n >> m) { // we are screwed for (int i=0; i<m; i++) { } } } #elif PROJECT == 6 int main() { unsigned long long m, p, l, e ,r, s, n; while (cin >> m >> p >> l >> e >> r >> s >> n) { for (int i = 0; i < n; i++) { int m1, p1, l1; m1 = p / s; p1 = l / r; l1 = m * e; m = m1; p = p1; l = l1; } cout << m << endl; } return 0; } #endif
--- c4.s1055.cteam098.grasshop.cpp.0.main.cpp +++ c4.s1152.cteam098.grasshop.cpp.0.main.cpp @@ -62,4 +63,11 @@ todo.pop(); + /*for (int i=1; i<=r; i++) + { + for (int j=1; j<=s; j++) + cout << " " << grid[i][j]; + cout << endl; + }*/ + for(vector< pair<int,int> >::iterator i = moves.begin(); i!=moves.end();i++) { @@ -69,14 +77,15 @@ if(grid[next.first][next.second]==-1) { grid[next.first][next.second]=grid[current.first][current.second]+1; - if(next==leaf) { - cout << grid[next.first][next.second] << endl; - } todo.push(next); } } } + //cout << endl << "/////////////////////////////" << endl; } if(grid[leaf.first][leaf.second]==-1) cout << "impossible" << endl; + else { + cout << grid[leaf.first][leaf.second] << endl; + } //1==1; } @@ -87,4 +96,17 @@ #elif PROJECT == 5 +int main() +{ + int n,m; + + while (cin >> n >> m) + { + // we are screwed + for (int i=0; i<m; i++) + { + } + } +} + #elif PROJECT == 6 @@ -94,6 +116,6 @@ while (cin >> m >> p >> l >> e >> r >> s >> n) { - for (ull i = 0; i < n; i++) { - ull m1, p1, l1; + for (int i = 0; i < n; i++) { + int m1, p1, l1; m1 = p / s; p1 = l / r;