QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#729656#6563. Four Squareahsoltan#WA 2196ms3828kbC++202.7kb2024-11-09 17:34:152024-11-09 17:34:16

Judging History

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

  • [2024-11-09 17:34:16]
  • 评测
  • 测评结果:WA
  • 用时:2196ms
  • 内存:3828kb
  • [2024-11-09 17:34:15]
  • 提交

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.second == p1.first) {
    swap(p0.first, p0.second);
  }

  if(p0.second == p1.second) {
    swap(p0.first, p0.second);
    swap(p1.first, p1.second);
    
  }

  debug(p0, p1);
  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() {

  debug(czy({2, 3}, {1, 3}, 3, 3));


  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)));
  }

  debug(bok);

  for(int x = 0; x < bok; x++) {
    for(int y = 0; y < x; y++) {
      sort(all(ve));
      do {
        vector<pair<int, int>> v2 = {
          {x, y},
          {bok - x, y},
          {bok, bok - y}
        };
        sort(all(v2));
        do{
          bool b0 = czy1(ve[0], v2[0].first, v2[0].second);
          bool b1 = czy1(ve[1], v2[1].first, v2[1].second);
          bool b2 = czy(ve[2], ve[3], v2[2].first, v2[2].second);
          if(x == 1 && y == 3) {
            debug(ve);
            debug(v2);
            debug(b0, b1, b2);
          }
          found |= b0 & b1 & b2;
        }
        while(next_permutation(all(v2)));
      }
      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: 0ms
memory: 3572kb

input:

1 1
1 1
1 1
1 1

output:

1

result:

ok single line: '1'

Test #2:

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

input:

3 1
3 3
2 2
3 3

output:

0

result:

ok single line: '0'

Test #3:

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

input:

2 8
2 8
2 8
2 8

output:

1

result:

ok single line: '1'

Test #4:

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

input:

5 3
5 5
3 3
3 5

output:

1

result:

ok single line: '1'

Test #5:

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

input:

1 2
4 8
16 32
64 128

output:

0

result:

ok single line: '0'

Test #6:

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

input:

4 4
2 1
4 4
2 1

output:

0

result:

ok single line: '0'

Test #7:

score: 0
Accepted
time: 241ms
memory: 3828kb

input:

995 51
559 565
154 536
56 780

output:

0

result:

ok single line: '0'

Test #8:

score: 0
Accepted
time: 335ms
memory: 3584kb

input:

391 694
540 42
240 937
691 246

output:

0

result:

ok single line: '0'

Test #9:

score: 0
Accepted
time: 386ms
memory: 3616kb

input:

519 411
782 710
299 45
21 397

output:

0

result:

ok single line: '0'

Test #10:

score: 0
Accepted
time: 162ms
memory: 3552kb

input:

96 960
948 18
108 82
371 576

output:

0

result:

ok single line: '0'

Test #11:

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

input:

3 2
4 3
3 1
1 4

output:

0

result:

ok single line: '0'

Test #12:

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

input:

4 3
1 2
4 4
3 2

output:

0

result:

ok single line: '0'

Test #13:

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

input:

4 4
1 3
5 4
2 5

output:

0

result:

ok single line: '0'

Test #14:

score: 0
Accepted
time: 110ms
memory: 3608kb

input:

1000 1000
1000 1000
1000 1000
1000 1000

output:

1

result:

ok single line: '1'

Test #15:

score: 0
Accepted
time: 2196ms
memory: 3548kb

input:

1000 999
998 1000
997 1000
997 997

output:

1

result:

ok single line: '1'

Test #16:

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

input:

1 3
3 3
3 3
4 7

output:

1

result:

ok single line: '1'

Test #17:

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

input:

2 5
5 4
7 1
6 2

output:

0

result:

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