Cod sursa(job #2105503)

Utilizator DruffbaumPopescu Vlad Druffbaum Data 13 ianuarie 2018 14:47:47
Problema Amlei Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.93 kb
#include <cstdio>
#include <vector>
#include <set>
#include <algorithm>

std::set <std::vector <int> > sa, sb;
std::vector <int> a, b;

int main() {
  int n, t, u, x;
  FILE *fin = fopen("amlei.in", "r");
  FILE *fout = fopen("amlei.out", "w");
  while (fscanf(fin, "%d%d%d", &n, &t, &u) != EOF) {
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < t; ++j) {
        fscanf(fin, "%d", &x);
        if (x > 0) {
          a.push_back(x);
        }
      }
    }
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < u; ++j) {
        fscanf(fin, "%d", &x);
        if (x > 0) {
          b.push_back(x);
        }
      }
    }
    std::sort(a.begin(), a.end());
    std::sort(b.begin(), b.end());
    sa.insert(a);
    sb.insert(b);
    fprintf(fout, "%s\n", sa == sb ? "DA" : "NU");
    a.clear();
    b.clear();
    sa.clear();
    sb.clear();
  }
  fclose(fin);
  fclose(fout);
  return 0;
}