Submission #495783

# Submission time Handle Problem Language Result Execution time Memory
495783 2021-12-20T05:09:01 Z Nalrimet Nice sequence (IZhO18_sequence) C++17
0 / 100
0 ms 204 KB
#include<bits/stdc++.h>

using namespace std;

const int N = 5 * 1e3 + 5;
const int inf = 1000000000;

#define int long long
#define F first
#define S second
#define pb push_back
#define ppb pop_back

int t, n, m, sum1, sum2 ;
vector<int> ans, v;

void rec(){
    if(n % m == 0 && ans.size() == n - 1){
        return;
    }
    if(m % n == 0 && ans.size() == m - 1){
        return;
    }
    cout << ans.size() << '\n';
    if(v.size() >= n){
        if(sum1 >= 0) return;
    }
    if(v.size() >= m){
        if(sum2 <= 0) return;
    }
    if(v.size() > ans.size()){
        ans = v;
    }
    if(v.size() >= n) sum1 -= v[v.size() - n];
    if(v.size() >= m) sum2 -= v[v.size() - m];
    for(int i = -10; i <= 10; ++i){
        sum1 += i;
        sum2 += i;
        v.pb(i);
        rec();
        v.ppb();
        sum1 -= i;
        sum2 -= i;
    }
    if(v.size() >= n) sum1 += v[v.size() - n];
    if(v.size() >= m) sum2 += v[v.size() - m];
}

//1
//6 2
//5
//-9 10 -9 10 -9

//1
//6 3
//5
//-10 1 10 -10 1

//1
//6 4
//7
//-7 -10 8 10 -7 -10 8

//1
//6 5
//9
//-3 -2 -2 -2 10 -3 -2 -2 -2

 main() {

//    ios_base::sync_with_stdio(0);
//    cin.tie(0);
//    cout.tie(0);

    cin >> t;

    while(t--){
        cin >> n >> m;
        if(n % m == 0){
            cout << n - 1 << '\n';
            for(int i = 1; i < n; ++i){
                cout << -1 << ' ';
            }
        }
        else{
            cout << m - 1 << '\n';
            for(int i = 1; i < m; ++i){
                cout << 1 << ' ';
            }
        }
        cout << '\n';
//        ans.clear();
//        rec();
//        cout << ans.size() << '\n';
//        for(auto to : ans){
//            cout << to << ' ';
//        }
    }

    return 0;

}

Compilation message

sequence.cpp: In function 'void rec()':
sequence.cpp:18:33: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   18 |     if(n % m == 0 && ans.size() == n - 1){
      |                      ~~~~~~~~~~~^~~~~~~~
sequence.cpp:21:33: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   21 |     if(m % n == 0 && ans.size() == m - 1){
      |                      ~~~~~~~~~~~^~~~~~~~
sequence.cpp:25:17: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   25 |     if(v.size() >= n){
      |        ~~~~~~~~~^~~~
sequence.cpp:28:17: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   28 |     if(v.size() >= m){
      |        ~~~~~~~~~^~~~
sequence.cpp:34:17: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   34 |     if(v.size() >= n) sum1 -= v[v.size() - n];
      |        ~~~~~~~~~^~~~
sequence.cpp:35:17: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   35 |     if(v.size() >= m) sum2 -= v[v.size() - m];
      |        ~~~~~~~~~^~~~
sequence.cpp:45:17: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   45 |     if(v.size() >= n) sum1 += v[v.size() - n];
      |        ~~~~~~~~~^~~~
sequence.cpp:46:17: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   46 |     if(v.size() >= m) sum2 += v[v.size() - m];
      |        ~~~~~~~~~^~~~
sequence.cpp: At global scope:
sequence.cpp:69:2: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   69 |  main() {
      |  ^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB there is incorrect sequence
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Jury has the better answer : jans = 3, pans = 1
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB there is incorrect sequence
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Jury has the better answer : jans = 3, pans = 2
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB there is incorrect sequence
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB there is incorrect sequence
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB there is incorrect sequence
2 Halted 0 ms 0 KB -