Я просматривал решения проблемы на Topcoder и наткнулся на это:
http://community.topcoder.com/stat?c=problem_solution&rm=249419&rd=9996&pm=6621&cr=309453
В настоящее время мне не интересно знать, как работает алгоритм, но для чего в коде используется оператор "‹ ?="? Я попытался скомпилировать код на своей машине, а также на ideone.com, но, к моему удивлению, код не скомпилировался. Что делает оператор и почему он не работает на стандартных компиляторах вроде ideone, а код проходит системные тесты на Topcoder?
Код здесь:
using namespace std;
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <ctype.h>
#include <string.h>
#include <string>
#include <sstream>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#define PB push_back
#define SZ size()
#define REP(v, hi) for (int v=0; v<(hi); v++)
#define REPD(v, hi) for (int v=((hi)-1); v>=0; v--)
#define FOR(v, lo, hi) for (int v=(lo); v<(hi); v++)
#define FORD(v, lo, hi) for (int v=((hi)-1); v>=(lo); v--)
typedef vector <int> VI;
typedef vector <VI> VVI;
typedef vector <VVI> VVVI;
/* ############################ THE REAL CODE ############################ */
class RoboRace {
public:
int startTime(vector <string> m, vector <string> _c) {
string c;
REP(i,_c.SZ) c+=_c[i];
int N=c.SZ;
int Y=m.SZ, X=m[0].SZ;
VVVI best(Y, VVI(X, VI(N+1, 99999)));
int ey=-1,ex=-1;
int yy=-1,yx=-1;
int fy=-1,fx=-1;
REP(y,Y) REP(x,X) {
if (m[y][x]=='Y') { yy=y; yx=x; m[y][x]='.'; }
if (m[y][x]=='F') { fy=y; fx=x; m[y][x]='.'; }
if (m[y][x]=='X') { ey=y; ex=x; m[y][x]='.'; }
}
REP(n,N+1) best[ey][ex][n]=n;
REPD(n,N) REP(y,Y) REP(x,X) {
if (m[y][x]=='#') continue;
best[y][x][n] <?= best[y][x][n+1];
if (c[n]=='N' && y>0) best[y][x][n] <?= best[y-1][x][n+1];
if (c[n]=='S' && y<Y-1) best[y][x][n] <?= best[y+1][x][n+1];
if (c[n]=='W' && x>0) best[y][x][n] <?= best[y][x-1][n+1];
if (c[n]=='E' && x<X-1) best[y][x][n] <?= best[y][x+1][n+1];
}
REP(n,N) if (best[yy][yx][n] < best[fy][fx][n]) return n;
return -1;
}
};
<?=
?? Никогда о таком не слышал... - person πάντα ῥεῖ   schedule 09.02.2014