QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#875112#8611. (A + B) mod Phos_lyricAC ✓11ms4096kbC++143.0kb2025-01-29 08:00:332025-01-29 08:00:33

Judging History

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

  • [2025-01-29 08:00:33]
  • 评测
  • 测评结果:AC
  • 用时:11ms
  • 内存:4096kb
  • [2025-01-29 08:00:33]
  • 提交

answer

#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

using Int = long long;

template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> ostream &operator<<(ostream &os, const vector<T> &as) { const int sz = as.size(); os << "["; for (int i = 0; i < sz; ++i) { if (i >= 256) { os << ", ..."; break; } if (i > 0) { os << ", "; } os << as[i]; } return os << "]"; }
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }
template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; }
template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; }
#define COLOR(s) ("\x1b[" s "m")


constexpr double PI = acos(-1.0);

constexpr int N = 24;

int P;
double A[110][N];
double B[110][N];

void judge() {
  for (int i0 = 0; i0 < P; ++i0) for (int i1 = 0; i1 < P; ++i1) {
    vector<double> sum(N);
    for (int j = 0; j < N; ++j) {
      sum[j] = max(A[i0][j] + A[i1][j], 0.0);
    }
    double mx = -1e+100;
    int im = -1;
    for (int i = 0; i < P; ++i) {
      double dot = 0.0;
      for (int j = 0; j < N; ++j) {
        dot += B[i][j] * sum[j];
      }
      if (chmax(mx, dot)) {
        im = i;
      }
    }
    // cerr << i0 << " " << i1 << ": " << im << " " << sum << endl;
    assert((i0 + i1) % P == im);
  }
}

int main() {
  for (; ~scanf("%d", &P); ) {
    for (int i = 0; i < P; ++i) {
      for (int j = 0; j < N; j += 4) {
        A[i][j + 0] = cos(j + 2*PI/P * i);
        A[i][j + 1] = sin(j + 2*PI/P * i);
        A[i][j + 2] = -A[i][j + 0];
        A[i][j + 3] = -A[i][j + 1];
      }
    }
    for (int i0 = 0; i0 < P; ++i0) for (int i1 = 0; i1 < P; ++i1) {
      for (int j = 0; j < N; ++j) {
        // chmax(B[(i0 + i1) % P][j], A[i0][j] + A[i1][j]);
        B[(i0 + i1) % P][j] += max(A[i0][j] + A[i1][j], 0.0);
      }
    }
    for (int i = 0; i < P; ++i) {
      double dot = 0.0;
      for (int j = 0; j < N; ++j) dot += B[i][j] * B[i][j];
      dot = sqrt(dot);
      for (int j = 0; j < N; ++j) B[i][j] /= dot;
    }
    
    printf("%d\n", N);
    for (int i = 0; i < P; ++i) {
      for (int j = 0; j < N; ++j) {
        if (j) printf(" ");
        printf("%f", A[i][j]);
      }
      puts("");
    }
    puts("");
    for (int i = 0; i < P; ++i) {
      for (int j = 0; j < N; ++j) {
        if (j) printf(" ");
        printf("%f", B[i][j]);
      }
      puts("");
    }
    
    judge();
  }
  return 0;
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3

output:

24
1.000000 0.000000 -1.000000 -0.000000 -0.653644 -0.756802 0.653644 0.756802 -0.145500 0.989358 0.145500 -0.989358 0.843854 -0.536573 -0.843854 0.536573 -0.957659 -0.287903 0.957659 0.287903 0.408082 0.912945 -0.408082 -0.912945
-0.500000 0.866025 0.500000 -0.866025 0.982232 -0.187671 -0.982232 0....

result:

ok OK

Test #2:

score: 0
Accepted
time: 1ms
memory: 4096kb

input:

5

output:

24
1.000000 0.000000 -1.000000 -0.000000 -0.653644 -0.756802 0.653644 0.756802 -0.145500 0.989358 0.145500 -0.989358 0.843854 -0.536573 -0.843854 0.536573 -0.957659 -0.287903 0.957659 0.287903 0.408082 0.912945 -0.408082 -0.912945
0.309017 0.951057 -0.309017 -0.951057 0.517775 -0.855517 -0.517775 0....

result:

ok OK

Test #3:

score: 0
Accepted
time: 1ms
memory: 4096kb

input:

7

output:

24
1.000000 0.000000 -1.000000 -0.000000 -0.653644 -0.756802 0.653644 0.756802 -0.145500 0.989358 0.145500 -0.989358 0.843854 -0.536573 -0.843854 0.536573 -0.957659 -0.287903 0.957659 0.287903 0.408082 0.912945 -0.408082 -0.912945
0.623490 0.781831 -0.623490 -0.781831 0.184152 -0.982898 -0.184152 0....

result:

ok OK

Test #4:

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

input:

11

output:

24
1.000000 0.000000 -1.000000 -0.000000 -0.653644 -0.756802 0.653644 0.756802 -0.145500 0.989358 0.145500 -0.989358 0.843854 -0.536573 -0.843854 0.536573 -0.957659 -0.287903 0.957659 0.287903 0.408082 0.912945 -0.408082 -0.912945
0.841254 0.540641 -0.841254 -0.540641 -0.140722 -0.990049 0.140722 0....

result:

ok OK

Test #5:

score: 0
Accepted
time: 1ms
memory: 4096kb

input:

13

output:

24
1.000000 0.000000 -1.000000 -0.000000 -0.653644 -0.756802 0.653644 0.756802 -0.145500 0.989358 0.145500 -0.989358 0.843854 -0.536573 -0.843854 0.536573 -0.957659 -0.287903 0.957659 0.287903 0.408082 0.912945 -0.408082 -0.912945
0.885456 0.464723 -0.885456 -0.464723 -0.227069 -0.973879 0.227069 0....

result:

ok OK

Test #6:

score: 0
Accepted
time: 1ms
memory: 4096kb

input:

17

output:

24
1.000000 0.000000 -1.000000 -0.000000 -0.653644 -0.756802 0.653644 0.756802 -0.145500 0.989358 0.145500 -0.989358 0.843854 -0.536573 -0.843854 0.536573 -0.957659 -0.287903 0.957659 0.287903 0.408082 0.912945 -0.408082 -0.912945
0.932472 0.361242 -0.932472 -0.361242 -0.336116 -0.941821 0.336116 0....

result:

ok OK

Test #7:

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

input:

19

output:

24
1.000000 0.000000 -1.000000 -0.000000 -0.653644 -0.756802 0.653644 0.756802 -0.145500 0.989358 0.145500 -0.989358 0.843854 -0.536573 -0.843854 0.536573 -0.957659 -0.287903 0.957659 0.287903 0.408082 0.912945 -0.408082 -0.912945
0.945817 0.324699 -0.945817 -0.324699 -0.372494 -0.928035 0.372494 0....

result:

ok OK

Test #8:

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

input:

23

output:

24
1.000000 0.000000 -1.000000 -0.000000 -0.653644 -0.756802 0.653644 0.756802 -0.145500 0.989358 0.145500 -0.989358 0.843854 -0.536573 -0.843854 0.536573 -0.957659 -0.287903 0.957659 0.287903 0.408082 0.912945 -0.408082 -0.912945
0.962917 0.269797 -0.962917 -0.269797 -0.425222 -0.905089 0.425222 0....

result:

ok OK

Test #9:

score: 0
Accepted
time: 1ms
memory: 4096kb

input:

29

output:

24
1.000000 0.000000 -1.000000 -0.000000 -0.653644 -0.756802 0.653644 0.756802 -0.145500 0.989358 0.145500 -0.989358 0.843854 -0.536573 -0.843854 0.536573 -0.957659 -0.287903 0.957659 0.287903 0.408082 0.912945 -0.408082 -0.912945
0.976621 0.214970 -0.976621 -0.214970 -0.475672 -0.879623 0.475672 0....

result:

ok OK

Test #10:

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

input:

31

output:

24
1.000000 0.000000 -1.000000 -0.000000 -0.653644 -0.756802 0.653644 0.756802 -0.145500 0.989358 0.145500 -0.989358 0.843854 -0.536573 -0.843854 0.536573 -0.957659 -0.287903 0.957659 0.287903 0.408082 0.912945 -0.408082 -0.912945
0.979530 0.201299 -0.979530 -0.201299 -0.487920 -0.872888 0.487920 0....

result:

ok OK

Test #11:

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

input:

37

output:

24
1.000000 0.000000 -1.000000 -0.000000 -0.653644 -0.756802 0.653644 0.756802 -0.145500 0.989358 0.145500 -0.989358 0.843854 -0.536573 -0.843854 0.536573 -0.957659 -0.287903 0.957659 0.287903 0.408082 0.912945 -0.408082 -0.912945
0.985616 0.169001 -0.985616 -0.169001 -0.516341 -0.856383 0.516341 0....

result:

ok OK

Test #12:

score: 0
Accepted
time: 2ms
memory: 3968kb

input:

41

output:

24
1.000000 0.000000 -1.000000 -0.000000 -0.653644 -0.756802 0.653644 0.756802 -0.145500 0.989358 0.145500 -0.989358 0.843854 -0.536573 -0.843854 0.536573 -0.957659 -0.287903 0.957659 0.287903 0.408082 0.912945 -0.408082 -0.912945
0.988280 0.152649 -0.988280 -0.152649 -0.530458 -0.847711 0.530458 0....

result:

ok OK

Test #13:

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

input:

43

output:

24
1.000000 0.000000 -1.000000 -0.000000 -0.653644 -0.756802 0.653644 0.756802 -0.145500 0.989358 0.145500 -0.989358 0.843854 -0.536573 -0.843854 0.536573 -0.957659 -0.287903 0.957659 0.287903 0.408082 0.912945 -0.408082 -0.912945
0.989343 0.145601 -0.989343 -0.145601 -0.536487 -0.843909 0.536487 0....

result:

ok OK

Test #14:

score: 0
Accepted
time: 2ms
memory: 4096kb

input:

47

output:

24
1.000000 0.000000 -1.000000 -0.000000 -0.653644 -0.756802 0.653644 0.756802 -0.145500 0.989358 0.145500 -0.989358 0.843854 -0.536573 -0.843854 0.536573 -0.957659 -0.287903 0.957659 0.287903 0.408082 0.912945 -0.408082 -0.912945
0.991077 0.133287 -0.991077 -0.133287 -0.546940 -0.837172 0.546940 0....

result:

ok OK

Test #15:

score: 0
Accepted
time: 1ms
memory: 4096kb

input:

53

output:

24
1.000000 0.000000 -1.000000 -0.000000 -0.653644 -0.756802 0.653644 0.756802 -0.145500 0.989358 0.145500 -0.989358 0.843854 -0.536573 -0.843854 0.536573 -0.957659 -0.287903 0.957659 0.287903 0.408082 0.912945 -0.408082 -0.912945
0.992981 0.118273 -0.992981 -0.118273 -0.559546 -0.828799 0.559546 0....

result:

ok OK

Test #16:

score: 0
Accepted
time: 3ms
memory: 3968kb

input:

59

output:

24
1.000000 0.000000 -1.000000 -0.000000 -0.653644 -0.756802 0.653644 0.756802 -0.145500 0.989358 0.145500 -0.989358 0.843854 -0.536573 -0.843854 0.536573 -0.957659 -0.287903 0.957659 0.287903 0.408082 0.912945 -0.408082 -0.912945
0.994335 0.106293 -0.994335 -0.106293 -0.569497 -0.821993 0.569497 0....

result:

ok OK

Test #17:

score: 0
Accepted
time: 3ms
memory: 4096kb

input:

61

output:

24
1.000000 0.000000 -1.000000 -0.000000 -0.653644 -0.756802 0.653644 0.756802 -0.145500 0.989358 0.145500 -0.989358 0.843854 -0.536573 -0.843854 0.536573 -0.957659 -0.287903 0.957659 0.287903 0.408082 0.912945 -0.408082 -0.912945
0.994700 0.102821 -0.994700 -0.102821 -0.572364 -0.820000 0.572364 0....

result:

ok OK

Test #18:

score: 0
Accepted
time: 3ms
memory: 4096kb

input:

67

output:

24
1.000000 0.000000 -1.000000 -0.000000 -0.653644 -0.756802 0.653644 0.756802 -0.145500 0.989358 0.145500 -0.989358 0.843854 -0.536573 -0.843854 0.536573 -0.957659 -0.287903 0.957659 0.287903 0.408082 0.912945 -0.408082 -0.912945
0.995606 0.093641 -0.995606 -0.093641 -0.579903 -0.814685 0.579903 0....

result:

ok OK

Test #19:

score: 0
Accepted
time: 5ms
memory: 4096kb

input:

71

output:

24
1.000000 0.000000 -1.000000 -0.000000 -0.653644 -0.756802 0.653644 0.756802 -0.145500 0.989358 0.145500 -0.989358 0.843854 -0.536573 -0.843854 0.536573 -0.957659 -0.287903 0.957659 0.287903 0.408082 0.912945 -0.408082 -0.912945
0.996087 0.088380 -0.996087 -0.088380 -0.584200 -0.811610 0.584200 0....

result:

ok OK

Test #20:

score: 0
Accepted
time: 4ms
memory: 4096kb

input:

73

output:

24
1.000000 0.000000 -1.000000 -0.000000 -0.653644 -0.756802 0.653644 0.756802 -0.145500 0.989358 0.145500 -0.989358 0.843854 -0.536573 -0.843854 0.536573 -0.957659 -0.287903 0.957659 0.287903 0.408082 0.912945 -0.408082 -0.912945
0.996298 0.085965 -0.996298 -0.085965 -0.586166 -0.810191 0.586166 0....

result:

ok OK

Test #21:

score: 0
Accepted
time: 6ms
memory: 4096kb

input:

79

output:

24
1.000000 0.000000 -1.000000 -0.000000 -0.653644 -0.756802 0.653644 0.756802 -0.145500 0.989358 0.145500 -0.989358 0.843854 -0.536573 -0.843854 0.536573 -0.957659 -0.287903 0.957659 0.287903 0.408082 0.912945 -0.408082 -0.912945
0.996839 0.079450 -0.996839 -0.079450 -0.591449 -0.806342 0.591449 0....

result:

ok OK

Test #22:

score: 0
Accepted
time: 7ms
memory: 4096kb

input:

83

output:

24
1.000000 0.000000 -1.000000 -0.000000 -0.653644 -0.756802 0.653644 0.756802 -0.145500 0.989358 0.145500 -0.989358 0.843854 -0.536573 -0.843854 0.536573 -0.957659 -0.287903 0.957659 0.287903 0.408082 0.912945 -0.408082 -0.912945
0.997136 0.075629 -0.997136 -0.075629 -0.594536 -0.804069 0.594536 0....

result:

ok OK

Test #23:

score: 0
Accepted
time: 9ms
memory: 3968kb

input:

89

output:

24
1.000000 0.000000 -1.000000 -0.000000 -0.653644 -0.756802 0.653644 0.756802 -0.145500 0.989358 0.145500 -0.989358 0.843854 -0.536573 -0.843854 0.536573 -0.957659 -0.287903 0.957659 0.287903 0.408082 0.912945 -0.408082 -0.912945
0.997509 0.070539 -0.997509 -0.070539 -0.598631 -0.801025 0.598631 0....

result:

ok OK

Test #24:

score: 0
Accepted
time: 11ms
memory: 4096kb

input:

97

output:

24
1.000000 0.000000 -1.000000 -0.000000 -0.653644 -0.756802 0.653644 0.756802 -0.145500 0.989358 0.145500 -0.989358 0.843854 -0.536573 -0.843854 0.536573 -0.957659 -0.287903 0.957659 0.287903 0.408082 0.912945 -0.408082 -0.912945
0.997903 0.064730 -0.997903 -0.064730 -0.603285 -0.797526 0.603285 0....

result:

ok OK

Extra Test:

score: 0
Extra Test Passed