Advertisement
Guest User

Untitled

a guest
Apr 14th, 2013
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.62 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <math.h>
  5. #include <ctype.h>
  6. #include <queue>
  7. #include <algorithm>
  8. #include <vector>
  9. #include <string>
  10. #include <utility>
  11. #include <iostream>
  12. #include <vector>
  13. using namespace std;
  14. typedef vector<int> vi;
  15. typedef vector<vi> vvi;
  16.  
  17. #define TRACE(x...)
  18. #define PRINT(x...) TRACE(printf(x))
  19. #define WATCH(x) TRACE(cout << #x" = " << x << endl)
  20.  
  21. #define all(v) (v).begin(), (v).end()
  22. #define rall(v) (v).rbegin(), (v).rend()
  23.  
  24. #define _FOR(it, b, e) for (typeof(b) it = (b); it != (e); ++it)
  25. #define foreach(x...) _FOR(x)
  26. #define fu(i, a) foreach(i, 0, a)
  27. #define forall(i, v) foreach(i, all(v))
  28.  
  29. #define MSET(c, v) memset(c, v, sizeof(c))
  30.  
  31. #define pb push_back
  32. #define sz(c) int((c).size())
  33.  
  34. const int INF = 0x3F3F3F3F; const int NEGINF = 0xC0C0C0C0;
  35. const double EPS = 1e-10;
  36.  
  37. inline int cmp(double x, double y = 0, double tol = EPS) {
  38.   return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1;
  39. }
  40.  
  41. int L[110][110];
  42.  
  43. bool mark[110][110];
  44.  
  45. int main() {
  46.     int T;
  47.     scanf("%d", &T);
  48.     fu(t, T) {
  49.         printf("Case #%d: ", t+1);
  50.         int N, M;
  51.         scanf("%d %d", &N, &M);
  52.         fu(i,N) fu(j,M) scanf("%d", &L[i][j]);
  53.         MSET(mark, false);
  54.         // horizontal
  55.         fu(i, N) {
  56.             int ma = L[i][0];
  57.             fu(j, M) ma = max(ma, L[i][j]);
  58.             fu(j, M) if (L[i][j] == ma) mark[i][j] = true;
  59.         }
  60.         // vertical
  61.         fu (j, M) {
  62.             int ma = L[0][j];
  63.             fu(i, N) ma = max(ma, L[i][j]);
  64.             fu(i, N) if (L[i][j] == ma) mark[i][j] = true;
  65.         }
  66.         bool ans = true;
  67.         fu(i, N) fu(j, M) if (!mark[i][j]) ans = false;
  68.         if (ans) printf("YES\n");
  69.         else printf("NO\n");
  70.     }
  71.     return 0;
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement