QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#729542#6563. Four Squareahsoltan#WA 1ms3700kbC++202.1kb2024-11-09 17:19:012024-11-09 17:19:11

Judging History

你现在查看的是最新测评结果

  • [2024-11-09 17:19:11]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3700kb
  • [2024-11-09 17:19:01]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define all(x) begin(x), end(x)
#define sz(x) int((x).size())
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

#ifdef LOCAL
auto operator<<(auto& o, auto x) -> decltype(x.first, o);
auto operator<<(auto& o, auto x) -> decltype(x.end(), o) {
  o << "{";
  for (int i = 0; auto y : x) o << ", " + !i++ * 2 << y;
  return o << "}";
}
auto operator<<(auto& o, auto x) -> decltype(x.first, o) {
  return o << "(" << x.first << ", " << x.second << ")";
}
void __print(auto... x) { ((cerr << x << " "), ...) << endl; }
#define debug(x...) __print("[" #x "]:", x)
#else
#define debug(...) 2137
#endif


bool czy(pair<int, int> p0, pair<int, int> p1, int x, int y) {
  if(p0.first == p1.second) {
    swap(p1.first, p1.second);
  }
  if(p0.first != p1.first)
    return 0;
  int s0 = p0.first;
  int s1 = p0.second + p1.second;
  if(s0 == x && s1 == y)
    return 1;
  if(s0 == y && s1 == x)
    return 1;
  return 0;
}

bool czy1(pair<int, int> p0, int x, int y) {
  if(x == p0.first && y == p0.second)
    return true;
  if(y == p0.first && x == p0.second)
    return true;
  return false;
}

int main() {
  cin.tie(0)->sync_with_stdio(0);
  vector<pair<int, int>> ve(4);
  int sm = 0;
  for(auto &[i, j] : ve) {
    cin >> i >> j;
    sm += i * j;
  }

  int bok = sqrt(sm);
  if(bok * bok != sm) {
    cout << 0 << endl;
    return 0;
  }

  bool found = 0;

  for(int x = 0; x < bok; x++) {
    sort(all(ve));
    do {
      if(czy(ve[0], ve[1], x, bok) && czy(ve[2], ve[3], bok - x, bok)) {
        found = 1;
      }
    }
    while(next_permutation(all(ve)));
  }

  for(int x = 0; x < bok; x++) {
    for(int y = 0; y < bok; y++) {
      sort(all(ve));
      do {
        bool b0 = czy1(ve[0], x, y);
        bool b1 = czy1(ve[1], bok - x, y);
        bool b2 = czy(ve[2], ve[3], bok, bok - y);
        found |= b0 & b1 & b2;
      }
      while(next_permutation(all(ve)));
    }
  }

  cout << found << endl;
  
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3700kb

input:

1 1
1 1
1 1
1 1

output:

1

result:

ok single line: '1'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3696kb

input:

3 1
3 3
2 2
3 3

output:

0

result:

ok single line: '0'

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3616kb

input:

2 8
2 8
2 8
2 8

output:

0

result:

wrong answer 1st lines differ - expected: '1', found: '0'