Runtime error (Access violation)
Послано
Ximera 15 мар 2013 23:25
Can not find mistake, it's crashing on 1 test. Can anybody help? Thnx.
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <cmath>
#include <vector>
#include <memory.h>
#include <stdio.h>
#include <fstream>
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
#define sc scanf
#define fi first
#define exp 1e-10
#define se second
#define pr printf
#define exp 1e-15
#define ll long long
#define mp make_pair
#define pb push_back
#define sqr(x) (x)*(x)
#define N (int)(1e+3)*2
#define mod (int)(1e+9)+7
#define inf (int)INFINITY/4
#define in(s) freopen(s, "r", stdin);
#define out(s) freopen(s, "w", stdout);
int dp[20][20];
bool us[20][20];
vector <int> x, y;
int main(){
int n, i, j, m, v, c;
cin >> n;
for(m = 1; m <= n; m++){
cin >> i >> j;
dp[i][j] = 1;
if(v == 0)
v = i, c = j;
}int k = 0;
cout << v << ' ' << c << "\n";
x.pb(v); y.pb(c);
while(!x.empty()){
v = x[0], c = y[0]; k++;
if(!us[v][c]){
if(!us[v + 1][c] && dp[v + 1][c] == 1)
dp[v + 1][c]++, cout << "R", x.pb(v + 1), y.pb(c);
if(!us[v][c + 1] && dp[v][c + 1] == 1)
dp[v][c + 1]++, cout << "T", x.pb(v), y.pb(c + 1);
if(!us[v - 1][c] && dp[v - 1][c] == 1)
dp[v - 1][c]++, cout << "L", x.pb(v - 1), y.pb(c);
if(!us[v][c - 1] && dp[v][c - 1] == 1)
dp[v][c - 1]++, cout << "B", x.pb(v), y.pb(c - 1);
if(k < n)
cout << ",\n";
else
cout << ".\n";
}
us[v][c] = true;
x.erase(x.begin());
y.erase(y.begin());
}
return 0;
}
Edited by author 15.03.2013 23:27