답안 #513593

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
513593 2022-01-17T09:42:50 Z Killer2501 Nice sequence (IZhO18_sequence) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsigned long long
#define pb push_back
#define pll pair<ll, ll>
#define pii pair<int, int>
#define fi first
#define se second
using namespace std;
const int N = 5e5+5;
const int M = (1<<17);
const ll inf = 1e15;
const ll mod = 1e15+7;
int n, t, k, m, d[N], in[N], out[N];
ll ans, tong, a[N], b[N], c[N];
string s[N];
struct node
{
    int x[2];
    set<int> vi;
    node(){}
    node( int _x, int _y)
    {
        x[0] = _x;
        x[1] = _y;
    }

};
vector<node> q;
vector<int> adj[N], kq;
void dfs(int u)
{
    a[u] = ++t;
    if(u+m <= k && a[u+m] == 0)dfs(u+m);
    if(u-n >= 0 && a[u-n] == 0)dfs(u-n);
}
bool check(int mid)
{
    k = mid;
    for(int i = 0; i <= k; i ++)adj[i].clear();
    fill_n(a, k+1, 0);
    t = 0;
    for(int i = 0; i <= k; i ++)
    {
        if(i+m <= k)
        {
            adj[i].pb(i+m);
            ++a[i+m];
        }
        if(i >= n)
        {
            adj[i].pb(i-n);
            ++a[i-n];
        }
    }
    queue<int> q;
    for(int i = 0; i <= k; i ++)if(a[i] == 0)q.push(i);
    while(!q.empty())
    {
        int u = q.front();
        q.pop();
        a[u] = ++t;
        for(int v: adj[u])
        {
            --a[v];
            if(a[v] == 0)q.push(v);
        }
    }
    if(t == k+1)return true;
    return false;
}
void sol()
{
    cin >> n >> m;
    ans = n+m-__gcd(m+n)-1;
    check(ans);
    cout << r << '\n';
    for(int i = 1; i <= r; i ++)cout << a[i]-a[i-1] <<" ";
    cout << '\n';
}
int main()
{
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    #define task "test"
    if(fopen(task".inp", "r"))
	{
		freopen(task".inp", "r", stdin);
		freopen(task".out", "w", stdout);
    }
    int ntest = 1;
    cin >> ntest;
    while(ntest -- > 0)
    sol();
}

Compilation message

sequence.cpp: In function 'void sol()':
sequence.cpp:76:24: error: no matching function for call to '__gcd(int)'
   76 |     ans = n+m-__gcd(m+n)-1;
      |                        ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from sequence.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:1219:5: note: candidate: 'template<class _EuclideanRingElement> _EuclideanRingElement std::__gcd(_EuclideanRingElement, _EuclideanRingElement)'
 1219 |     __gcd(_EuclideanRingElement __m, _EuclideanRingElement __n)
      |     ^~~~~
/usr/include/c++/10/bits/stl_algo.h:1219:5: note:   template argument deduction/substitution failed:
sequence.cpp:76:24: note:   candidate expects 2 arguments, 1 provided
   76 |     ans = n+m-__gcd(m+n)-1;
      |                        ^
sequence.cpp:78:13: error: 'r' was not declared in this scope
   78 |     cout << r << '\n';
      |             ^
sequence.cpp: In function 'int main()':
sequence.cpp:90:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   90 |   freopen(task".inp", "r", stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
sequence.cpp:91:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   91 |   freopen(task".out", "w", stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~