// edge marker program
#include <iostream.h>
#include <fstream.h>
#include <string.h>
#include <stdio.h>

int N, M;
const MAX = 110;
char G[MAX][MAX];

char C[MAX][MAX];  // all cols. for a guy
char D[MAX][MAX];  // all cols. for a task
char F[MAX][MAX];  // frequency check

int main(int argc, char ** argv)
{
 int evil = 0;

 if (argc != 3) { cout << "USAGE: <student's file> <input file>" << endl; return 1;};

 // read input
 ifstream in; in.open(argv[2]);
 ifstream student; student.open(argv[1]);

 if (in.bad() || student.bad()) { cout << "Could not open files" << endl; return 1;};

 int CASE = 1;
 while (1)
 {
  in >> N >> M;
  if (N < 0) break;

  memset(G, 0, sizeof(G));
  memset(F, 0, sizeof(F));
  memset(C, 0, sizeof(C));
  memset(D, 0, sizeof(D));

  int degree = 0;
  int i,j;

  // assume integers 1..N on left side, 1..M on the right
  while (1)
  {
    int x, y, times;

    in >> x >> y >> times;
    if (x < 0) break;

    for (int ii=0; ii < times; ii++)
    {
     G[x][0] ++;                if (G[x][0] > degree) degree = G[x][0];
     G[x][ G[x][0] ] = y;

     F[x][y] ++;
    }

  }

  // check degree of tasks
  for (int k=1; k <= M; k++)
  {
   int deg = 0;
   for (int i=1; i <= N; i++)
    for (int j=1; j <= G[i][0]; j++)
     if (G[i][j] == M) deg++;
   if (deg > degree) degree = deg;
  }

  // read their input

  int blah;
  student >> blah;

  if (blah != degree) {evil = 1; break;};

  char line[10*100 + 100];
  // skip shit
  student.getline(line, 100);

  // read input and make sure it matches ours
  for (int ii=0; ii < degree; ii++)
  {
   student.getline(line, 1100);
   char * cur = line;
   while (strchr(cur, ')') != NULL && *cur != '\0')
   {
    int guy, task;
    sscanf(cur, "%d (%d)", &guy, &task);

    // verify this dude
    F[guy][task]--;

    // colour
    C[guy][ ++C[guy][0] ] = ii+1;
    D[task][ ++D[task][0] ] = ii+1;


    cur = strchr(cur, ')') + 1;
    while (*cur != '\0' && *cur == ' ') cur++;
   }
  }

  // verify frequencies
  for (i=1; i <= N; i++)
   for (j=1; j <= M; j++)
    if (F[i][j] != 0) evil = 2;

  if (evil) break;

  // verify colouring
  for (i = 1; i <= N; i++)
  {
   int f[MAX];
   memset(f, 0, sizeof(f));

   for (j = 1; j <= C[i][0]; j++)  // verify all these are different colours
    f[ C[ i ][ j ] ] ++;
   

   for (j=0; j < MAX; j++)
    if (f[j] > 1) evil = 3;
  }

  for (i = 1; i <= M; i++)
  {
   int f[MAX];
   memset(f, 0, sizeof(f));

   for (j = 1; j <= D[i][0]; j++)  // verify all these are different colours   
    f[ D[ i ][j] ] ++;
   

   for (j=0; j < MAX; j++)
    if (f[j] > 1) evil = 4;
  }

  if (evil) break;

  CASE++;

 }

 if (evil != 0)
  cout << "BAD RUN (error " << evil << "); case # " << CASE << endl;
 else
  cout << "SUCCESS!" << endl;

 in.close();
 student.close();

}
Downloader failed!
Response object
006~ASP 0159~Buffering Off~Buffering must be on.