QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#826069#9768. A + B = C Problemucup-team3099#WA 1ms3828kbC++234.0kb2024-12-22 02:20:592024-12-22 02:21:00

Judging History

This is the latest submission verdict.

  • [2024-12-22 02:21:00]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 3828kb
  • [2024-12-22 02:20:59]
  • Submitted

answer

#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <cassert>

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / (long long) gcd(a, b) * b; }

int main() {
    std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
    int t;
    std::cin >> t;
    while(t--) {
        int a, b, c;
        std::cin >> a >> b >> c;
        if(lcm(a, b) % c != 0) {
            std::cout << "NO\n";
        } else {
            std::string str[3];
            str[0].assign(a, '0');
            str[1].assign(b, '0');
            str[2].assign(c, '0');
            int A = 1, B = 1;
            for(int i = 2, rest = c; i <= c; i++) {
                if(rest % i != 0) {
                    continue;
                }
                int f = 0;
                while(a % i == 0) f++, a /= i;
                while(b % i == 0) f--, b /= i;
                while(rest % i == 0) {
                    rest /= i;
                    if(f >= 0) {
                        A *= i;
                    } else {
                        B *= i;
                    }
                }
            }
            for(int i = A-1; i < (int) str[0].size(); i += A) {
                str[0][i] ^= 1;
            }
            for(int i = B-1; i < (int) str[1].size(); i += B) {
                str[1][i] ^= 1;
            }
            for(int i = A-1; i < (int) str[2].size(); i += A) {
                str[2][i] ^= 1;
            }
            for(int i = B-1; i < (int) str[2].size(); i += B) {
                str[2][i] ^= 1;
            }
            std::cout << "YES\n" << str[0] << '\n' << str[1] << '\n' << str[2] << '\n';
        }
    }
}

/*
NEVER FORGET TO:
    Look at the problem's constraints before coding.
How to cheese cf:
    Find a lower bound or upper bound for the problem. Have faith that it is the answer of the problem.
    If it isn't the answer, have more faith or change to another bound god by looking for a better bound.

    Trust guesses. Who has time to think? If people in div2 AC the problem it requires no proof since people don't prove things.

    You must draw cases. Thinking gets you nowhere, so draw cases and reach illogical conclusions from them.
    Sometimes drawing cases is bad because it takes too much time. Faster is to not think at all and just code a bruteforce solution.
    This is called "law of small numbers". If something works for small numbers, surely it works for big numbers.
    https://en.wikipedia.org/wiki/Faulty_generalization#Hasty_generalization don't mind the "faulty" part of it, in competitive programming mistakes are lightly punished
    Don't think about them being right or not, cf is a battle of intuition only.

    Be as stupid as possible in implementation. Trying to be smart is an easy way to get WA.

    Think about 2x2 cases for matrix problems and hope that everything works for the general case.

    Find a necessary condition and trust it to be sufficient. They're basically the same thing.

    Heuristics might speed up your code. Forget about complexity, it's only about ACing and not proving that your solution is good.

    For paths in a grid starting at (1, i) or something like that, assume that they never cross and do D&C

    Consider doing problems in reverse order of queries/updates

    For combinatorics problems, consider symmetry

    For problems that are similar to past problems, think about the differences betweem it and the current problem.
    Sometimes the difference makes no difference. Sometimes it does.

General strategy (MUST DO):
    Try to solve the problem with more restricted constraints.

About testing:
    Test n=1, a[i]=1, a[i]=n, etc. Basically, test low values. No need to test if pretests are strong, but if you get WA it's good.

This isn't a joke. Do it if you get stuck. It's shit practice in my opinion, but do it if you want AC.
*/

詳細信息

Test #1:

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

input:

2
2 3 6
2 3 5

output:

YES
01
001
011100
NO

result:

ok ok (2 test cases)

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 3592kb

input:

1214
940 746 485
304 504 661
815 674 830
704 774 691
545 597 924
330 894 320
491 425 479
768 869 698
706 480 785
358 548 504
999 473 363
532 950 745
512 682 364
829 832 959
570 931 317
324 543 362
590 421 737
326 483 503
958 890 793
836 721 518
720 361 363
730 402 753
810 416 585
781 953 490
623 360...

output:

NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
01010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010...

result:

wrong answer Impossible case! (test case 16)