示例#1
0
int main(int argc, char * argv[])
{
  registerTestlibCmd(argc, argv);

  int n = inf.readInt();
  while (!ouf.seekEof()) {
    int k = ouf.readInt(1, n);
    
    for (int i = 0; i < n; ++i)
      a[i] = 0;
    for (int i = 0; i < k; ++i) {
      int j = ouf.readInt(1, n) - 1;
      a[j]++;
    }
    
    int x = 0;
    for (int i = 0; i < n; ++i) {
      if (a[i] > 1)
        quit(_wa, "Same student appears more than once");
      x = x * 2 + a[i];
    }
    c[x]++;
  }

  for (int i = 1; i < (1 << n); ++i) {
    if (c[i] == 0)
      quitf(_wa, "Subset #%d not found", i);
    if (c[i] > 1)
      quitf(_wa, "Subset #%d appears more than once", i);
  }

  quit(_ok, "");
}
示例#2
0
int main(int argc, char * argv[])
{
    registerTestlibCmd(argc, argv);
    
    n = inf.readInt();
//    s = inf.readInt();
//    for (int i = 0; i < n; i++) {
//    	left[i] = inf.readInt();
//    	right[i] = inf.readInt();
//    	cost[i] = inf.readInt();	
//    }
    for (int i = 0; i < n; i++) {
    	long long y1 = ans.readLong();
    	long long y2 = ouf.readLong();
    	if (y1 != y2) {
    		quitf(_wa, "line %d: expected %s, found %s", i, vtos(y1).c_str(), vtos(y2).c_str());		
    	}
    	if (y1 != -1) {
			std::string s1;
			std::string s2;
			s1 = ans.readToken();
			s2 = ouf.readToken();
			if (s1 != s2) {
				if (s2 != "YES" && s2 != "NO") {
					quitf(_pe, "line %d: incorrect answer %s", i, s2.c_str());	
				}
				quitf(_wa, "line %d: expected %s, found %s", i, s1.c_str(), s2.c_str());		
			}
    	}
    } 
    quitf(_ok, "answer is correct");
}
示例#3
0
int main(int argc, char * argv[])
{
    setName("compare two doubles, maximal absolute error = %.10lf", EPS);
    registerTestlibCmd(argc, argv);
    
    double ja = ans.readDouble();
    double pa = ouf.readDouble();
    
    if (fabs(ja - pa) > EPS)
        quitf(_wa, "expected %.10lf, found %.10lf", ja, pa);
    
    quitf(_ok, "answer is %.10lf", ja);
}
示例#4
0
int main(int argc, char * argv[])
{
    setName("compare two signed int%ld's", 8 * sizeof(int));
    registerTestlibCmd(argc, argv);
    
    int ja = ans.readInt();
    int pa = ouf.readInt();
    
    if (ja != pa)
        quitf(_wa, "expected %d, found %d", ja, pa);
    
    quitf(_ok, "answer is %d", ja);
}
示例#5
0
int main(int argc, char ** argv)
{
  registerTestlibCmd(argc, argv);

  int n = inf.readInt();
  int c[n + 1];
  c[0] = 1;
  c[1] = 1;
  for (int i = 2; i <= n; ++i) {
    c[i] = 0;
    for (int j = 0; j <= i - 1; ++j)
      c[i] += c[j] * c[i - 1 - j];
  }
    
  int p[2][2*n];
  for (int i = 0; i < c[n]; ++i) {
    int b = 0;
    for (int j = 0; j < 2 * n; ++j) {
      char c = ouf.readChar();
      if (c != '(' && c != ')')
        quitf(_wa, "incorrect character in line #%d", i + 1);

      p[i & 1][j] = c == '(' ? -1 : 1;
      b += p[i & 1][j];
      if (b > 0)
        quitf(_wa, "sequence #%d is not balanced", i + 1);        
    }
    if (b != 0)
      quitf(_wa, "sequence #%d is not balanced", i + 1);        

    if (i) {
      int j;
      for (j = 0; j < 2 * n && p[0][j] == p[1][j]; ++j)
        ;
      if (j == 2 * n)
        quitf(_wa, "sequence #%d is the same as the sequence #%d", i + 1, i);

      if (p[i & 1][j] < p[1 - (i & 1)][j])
        quitf(_wa, "sequence #%d is less than the sequence #%d", i + 1, i);
    }
    ouf.nextLine();
  }

  quit(_ok, "");

  return 0;
}
示例#6
0
int main(int argc, char* argv[ ]) {
    setName("compare two sequences of doubles, max absolute or relative error = %.9f", EPS);
    registerTestlibCmd(argc, argv);
    int n = 0;
    double j = 0, p = 0;
    while (!ans.seekEof()) {
        n++;
        j = ans.readDouble();
        p = ouf.readDouble();
        if (!doubleCompare(j, p, EPS))
            quitf(_wa, "%d%s numbers differ: expected '%.9f', found '%.9f', error '%.9f'",
                n, englishEnding(n).c_str(), j, p, doubleDelta(j, p)
            );
    }
    if (n == 1)
        quitf(_ok, "found '%.9f', expected '%.9f', error '%.9f'", p, j, doubleDelta(j, p));
    quitf(_ok, "%d numbers", n);
}
int main(int argc, char* argv[]) {
    registerValidation();
    int n = inf.readInt(1, 10000, "Number points");
    inf.readEoln();
    std::vector<Point> points;
    for(size_t i = 0; i < n; ++i) {
        Point point;
        point.x = inf.readInt(-500, 500, "x coordinate");
        inf.readSpace();
        point.y = inf.readInt(-500, 500, "y coordinate");
        inf.readSpace();
        point.z = inf.readInt(-500, 500, "z coordinate");
        points.push_back(point);
        inf.readEoln();
    }
    inf.readEof();

    for(int i = 0; i < n; i++) {
        for(int j = 0; j < i; ++j) {
            for(int k = 0; k < j; ++k) {
                const Plane plane(points[i], points[j], points[k]);
                for(int t = 0; t < n; ++t) {
                    if (t == i || t == j || t == k) continue;
                    if (plane.contains(points[t])) {
                        std::stringstream message;
                        message << "Four points on the same plane : " << k << " " << j << " " << i << " " << t;
                        quitf(_fail, message.str().c_str()); 
                    }
                }
            }
        }
    }

    
    return 0;
}