Submission #805565

# Submission time Handle Problem Language Result Execution time Memory
805565 2023-08-03T17:53:46 Z farhan132 Nice sequence (IZhO18_sequence) C++17
6 / 100
1 ms 328 KB
/***Farhan132***/
// #pragma GCC optimize("Ofast,fast-math")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
// #pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef double dd;
typedef pair<ll , ll> ii;
typedef tuple < ll,  ll, ll > tp;
 
#define ff first
#define ss second
#define pb push_back
#define in insert
#define bug printf("**!\n")
#define mem(a , b) memset(a, b ,sizeof(a))
#define front_zero(n) __builtin_clz(n)
#define back_zero(n) __builtin_ctzll(n)
#define total_one(n) __builtin_popcount(n)
#define clean fflush(stdout)
 
const ll mod =  (ll) 998244353;
// const ll mod =  (ll) 1e9 + 7;
//const ll INF = numeric_limits<ll>::max()-1;
const ll INF = (ll)2e18;
 
// ll dx[]={0,1,0,-1};
// ll dy[]={1,0,-1,0};
// ll dxx[]={0,1,0,-1,1,1,-1,-1};
// ll dyy[]={1,0,-1,0,1,-1,1,-1};
 
mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
 
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const ll N = 2005;

vector < ll > f(ll n, ll m){
    if(n > m){
        vector < ll > v = f(m, n);
        for(auto &u : v) u = -u;
        return v;
    }
    if(n == m){
        vector < ll > v(n - 1, 1);
        return v;
    }
    if(n * 2 <= m){
        vector < ll > v(m - 1, 1);
        return v;
    }
    ll intersect = n * 2 - m;
    ll sub = (m - intersect) / 2;
    assert(2*sub + intersect == m);
    vector < ll > v(m); 
    ll R = 5e7;
    for(ll i = 0; i < sub; i++){
        v[i] = -1; R--;
    }
    v[0] -= R; 
    R = 1e8;
    for(ll i = sub; i < sub + intersect; i++){
        v[i] = 1; R--;
    }
    v[sub] += R;
    for(ll i = sub + intersect; i < m; i++){
        v[i] = v[i - n];
    }
    v[m - 1]--;
    return v;
}

void solve(){

    ll n, m; cin >> n >> m;

    auto v = f(m, n);

    cout << v.size() << '\n';
    for(auto u : v){
        cout << u << ' ';
    }
    cout << '\n';
    
   return;
}

int main() {

    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
        auto start_time = clock();
    #else
         // freopen("subsequence.in", "r", stdin);
         // freopen("subsequence.out", "w", stdout); 
         ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    #endif

    //precalc();
 
    ll T = 1, CT = 0; cin >> T; 
 
    while(T--){
        // cout << "Case #" << ++CT << ": ";
        solve();
    }
    
    #ifdef LOCAL
        auto end_time = clock();
        cerr<< "Execution time: "<<(end_time - start_time)*(int)1e3/CLOCKS_PER_SEC<<" ms\n";
    #endif
 
    return 0;
} 

Compilation message

sequence.cpp: In function 'int main()':
sequence.cpp:110:15: warning: unused variable 'CT' [-Wunused-variable]
  110 |     ll T = 1, CT = 0; cin >> T;
      |               ^~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Ok
2 Correct 1 ms 212 KB Ok
3 Correct 1 ms 324 KB Ok
4 Correct 1 ms 212 KB Ok
5 Correct 1 ms 212 KB Ok
6 Correct 1 ms 212 KB Ok
7 Correct 1 ms 212 KB Ok
8 Correct 1 ms 212 KB Ok
9 Correct 1 ms 212 KB Ok
10 Correct 1 ms 212 KB Ok
11 Correct 1 ms 328 KB Ok
12 Correct 1 ms 320 KB Ok
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Jury has the better answer : jans = 5, pans = 4
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Ok
2 Correct 1 ms 212 KB Ok
3 Incorrect 0 ms 212 KB Jury has the better answer : jans = 5, pans = 4
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Jury has the better answer : jans = 5, pans = 4
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Ok
2 Correct 1 ms 212 KB Ok
3 Correct 1 ms 324 KB Ok
4 Correct 1 ms 212 KB Ok
5 Correct 1 ms 212 KB Ok
6 Correct 1 ms 212 KB Ok
7 Correct 1 ms 212 KB Ok
8 Correct 1 ms 212 KB Ok
9 Correct 1 ms 212 KB Ok
10 Correct 1 ms 212 KB Ok
11 Correct 1 ms 328 KB Ok
12 Correct 1 ms 320 KB Ok
13 Correct 1 ms 212 KB Ok
14 Correct 1 ms 212 KB Ok
15 Incorrect 0 ms 212 KB Jury has the better answer : jans = 5, pans = 4
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Ok
2 Correct 1 ms 212 KB Ok
3 Correct 1 ms 324 KB Ok
4 Correct 1 ms 212 KB Ok
5 Correct 1 ms 212 KB Ok
6 Correct 1 ms 212 KB Ok
7 Correct 1 ms 212 KB Ok
8 Correct 1 ms 212 KB Ok
9 Correct 1 ms 212 KB Ok
10 Correct 1 ms 212 KB Ok
11 Correct 1 ms 328 KB Ok
12 Correct 1 ms 320 KB Ok
13 Incorrect 1 ms 212 KB Jury has the better answer : jans = 5, pans = 4
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Ok
2 Correct 1 ms 212 KB Ok
3 Correct 1 ms 324 KB Ok
4 Correct 1 ms 212 KB Ok
5 Correct 1 ms 212 KB Ok
6 Correct 1 ms 212 KB Ok
7 Correct 1 ms 212 KB Ok
8 Correct 1 ms 212 KB Ok
9 Correct 1 ms 212 KB Ok
10 Correct 1 ms 212 KB Ok
11 Correct 1 ms 328 KB Ok
12 Correct 1 ms 320 KB Ok
13 Incorrect 1 ms 212 KB Jury has the better answer : jans = 5, pans = 4
14 Halted 0 ms 0 KB -