ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1334. Checkers

Why Wa !?
Posted by The Cheater 17 Oct 2004 18:38
#include <iostream>
using namespace std;
const int n = 8;
int LD[2*(n+2)]; // left diagonal
int RD[2*(n+2)]; // right diagonal
int row[n+1]; // the row

int main() {
    int i;
    int x,y;
    char c;
    memset(LD,0,sizeof LD); memset(RD,0,sizeof RD); memset(row,0,sizeof row);
    for(i=0;i<32;i++) {
        cin >> c >> y;
        x = c-'a'+1; //
        if(!LD[n-x+y] && !RD[x+y] && !row[y]) { // checks
            LD[n-x+y] = RD[x+y] = row[y] = 1;
        }
        else {
            cout << i+1 << endl; // one can hit other
            cin >> c;
            return 0;
        }
    }
    cout << "Draw" << endl; // is this case possible ?
    return 0;
}