답안 #412169

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
412169 2021-05-26T15:09:05 Z arayi Nice sequence (IZhO18_sequence) C++17
15 / 100
16 ms 1548 KB
//Arayi
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <math.h>
#include <vector>
#include <cstring>
#include <ctime>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <ctime>
#include <climits>
#include <cassert>
#include <chrono>
#include <random>
#include <complex>

#define fr first
#define sc second
#define MP make_pair
#define ad push_back
#define PB push_back
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define lli long long int
#define y1 arayikhalatyan
#define j1 jigglypuff
#define ld long double
#define itn int
#define pir pair<int, int>
#define all(x) (x).begin(), (x).end()
#define str string
#define enl endl
#define en endl
#define cd complex<long double>
#define vcd vector<cd>
#define vii vector<int>
#define vlli vector<lli>
using namespace std;

lli gcd(lli a, lli b) { return (b == 0LL ? a : gcd(b, a % b)); }
ld dist(ld x, ld y1, ld x2, ld y2)
{
    return sqrt((x - x2) * (x - x2) + (y1 - y2) * (y1 - y2));
}
lli S(lli a)
{
    return (a * (a + 1LL)) / 2;
}
mt19937 rnd(363542);
char vow[] = { 'a', 'e', 'i', 'o', 'u' };
int dx[] = { 0, -1, 0, 1, -1, -1, 1, 1, 0 };
int dy[] = { -1, 0, 1, 0, -1, 1, -1, 1, 0 };


const int N = 1e6 + 30;
const lli mod = 1e9 - 1;
const ld pi = acos(-1);
const int T = 550;

lli bp(lli a, lli b = mod - 2LL)
{
    lli ret = 1;
    while (b)
    {
        if (b & 1) ret *= a, ret %= mod;
        a *= a;
        a %= mod;
        b >>= 1;
    }
    return ret;
}
ostream& operator<<(ostream& c, pir a)
{
    c << a.fr << " " << a.sc;
    return c;
}
template<class T>
void maxi(T& a, T b)
{
    a = max(a, b);
}
template <class T>
void mini(T& a, T b)
{
    a = min(a, b);
}


int n, m;
int t;
void tp(vii fp)
{
    cout << fp.size() << endl;
    for(auto p : fp) cout << p << " ";
    cout << endl;
}
int main()
{
    fastio;
    cin >> t;
    while(t--)
    {
        cin >> n >> m;
        vii fp;
        if(n == m)
        {
            for (int i = 0; i < n - 1; i++) fp.ad(1);
            tp(fp);
            continue;
        }
        int bl = 1;
        if(n > m) swap(n, m), bl = -1;
        if(n==1)
        {
            for (int i = 0; i < m - 1; i++) fp.ad(-bl);
            tp(fp);
            continue;
        }
        int x = mod / n;
        if(x*(n-2) == mod + 1) x--;
        for (int i = 1; i <= m + n/gcd(n, m) - 2; i++)
        {
            if(i % n == 0) fp.ad(-bl * (mod + 1 - (n - 2)*x));
            else if(i % n == n - 1) fp.ad(bl * mod);
            else fp.ad(-bl*x);
        }
        tp(fp);
    }
    return 0;
}

/*
5 4 4
1 2
3 1
3 4
5 3
4 5 2 3
2 1 3 1
1 3 5
2 3 4 5
2 1 3 1
    __
  *(><)*
    \/ /
    ||/
  --||
    ||
    /\
   /  \
  /    \

*/
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Ok
2 Correct 1 ms 320 KB Ok
3 Correct 1 ms 216 KB Ok
4 Correct 1 ms 204 KB Ok
5 Correct 1 ms 204 KB Ok
6 Correct 1 ms 312 KB Ok
7 Correct 1 ms 204 KB Ok
8 Correct 1 ms 204 KB Ok
9 Correct 1 ms 204 KB Ok
10 Correct 1 ms 204 KB Ok
11 Correct 1 ms 204 KB Ok
12 Correct 1 ms 204 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Ok
2 Correct 1 ms 204 KB Ok
3 Correct 1 ms 204 KB Ok
4 Correct 1 ms 204 KB Ok
5 Correct 1 ms 204 KB Ok
6 Correct 3 ms 460 KB Ok
7 Correct 13 ms 1356 KB Ok
8 Correct 6 ms 716 KB Ok
9 Correct 16 ms 1548 KB Ok
10 Correct 9 ms 972 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Ok
2 Correct 1 ms 204 KB Ok
3 Correct 1 ms 204 KB Ok
4 Incorrect 1 ms 204 KB there is incorrect sequence
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB there is incorrect sequence
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Ok
2 Correct 1 ms 320 KB Ok
3 Correct 1 ms 216 KB Ok
4 Correct 1 ms 204 KB Ok
5 Correct 1 ms 204 KB Ok
6 Correct 1 ms 312 KB Ok
7 Correct 1 ms 204 KB Ok
8 Correct 1 ms 204 KB Ok
9 Correct 1 ms 204 KB Ok
10 Correct 1 ms 204 KB Ok
11 Correct 1 ms 204 KB Ok
12 Correct 1 ms 204 KB Ok
13 Correct 1 ms 204 KB Ok
14 Correct 1 ms 204 KB Ok
15 Correct 1 ms 204 KB Ok
16 Incorrect 1 ms 204 KB there is incorrect sequence
17 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Ok
2 Correct 1 ms 320 KB Ok
3 Correct 1 ms 216 KB Ok
4 Correct 1 ms 204 KB Ok
5 Correct 1 ms 204 KB Ok
6 Correct 1 ms 312 KB Ok
7 Correct 1 ms 204 KB Ok
8 Correct 1 ms 204 KB Ok
9 Correct 1 ms 204 KB Ok
10 Correct 1 ms 204 KB Ok
11 Correct 1 ms 204 KB Ok
12 Correct 1 ms 204 KB Ok
13 Correct 1 ms 332 KB Ok
14 Correct 1 ms 204 KB Ok
15 Correct 1 ms 204 KB Ok
16 Correct 1 ms 204 KB Ok
17 Correct 1 ms 204 KB Ok
18 Correct 3 ms 460 KB Ok
19 Correct 13 ms 1356 KB Ok
20 Correct 6 ms 716 KB Ok
21 Correct 16 ms 1548 KB Ok
22 Correct 9 ms 972 KB Ok
23 Correct 1 ms 204 KB Ok
24 Correct 1 ms 204 KB Ok
25 Correct 1 ms 204 KB Ok
26 Incorrect 1 ms 204 KB there is incorrect sequence
27 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Ok
2 Correct 1 ms 320 KB Ok
3 Correct 1 ms 216 KB Ok
4 Correct 1 ms 204 KB Ok
5 Correct 1 ms 204 KB Ok
6 Correct 1 ms 312 KB Ok
7 Correct 1 ms 204 KB Ok
8 Correct 1 ms 204 KB Ok
9 Correct 1 ms 204 KB Ok
10 Correct 1 ms 204 KB Ok
11 Correct 1 ms 204 KB Ok
12 Correct 1 ms 204 KB Ok
13 Correct 1 ms 332 KB Ok
14 Correct 1 ms 204 KB Ok
15 Correct 1 ms 204 KB Ok
16 Correct 1 ms 204 KB Ok
17 Correct 1 ms 204 KB Ok
18 Correct 3 ms 460 KB Ok
19 Correct 13 ms 1356 KB Ok
20 Correct 6 ms 716 KB Ok
21 Correct 16 ms 1548 KB Ok
22 Correct 9 ms 972 KB Ok
23 Correct 1 ms 204 KB Ok
24 Correct 1 ms 204 KB Ok
25 Correct 1 ms 204 KB Ok
26 Incorrect 1 ms 204 KB there is incorrect sequence
27 Halted 0 ms 0 KB -