#include<bits/stdc++.h>
#define fr first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
#define USING_ORDERED_SET 0
#if USING_ORDERED_SET
#include<bits/extc++.h>
using namespace __gnu_pbds;
template<class T>using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
#endif
template<class T>void umax(T &a,T b){if(a<b)a=b;}
template<class T>void umin(T &a,T b){if(b<a)a=b;}
#ifdef juggernaut
#define printl(args...) printf(args)
#else
#define printl(args...) 0
#endif
int n, m;
int timer, len;
bool used[800005];
int pref[400005];
void dfs(int v){
used[v] = true;
{
int to = v - m;
if(to >= 0 && !used[to])
dfs(to);
}
{
int to = v + n;
if(to <= len && !used[to])
dfs(to);
}
pref[v] = timer++;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int tests;
tests = 1;
while(tests--){
cin >> n >> m;
priority_queue<int, vector<int>, greater<int> >q;
int mx = 0;
timer = 0;
q.push(0);
while(!q.empty()){
int v = q.top();
q.pop();
used[v] = 1;
umax(mx, v);
{
int to = v - m;
if(to >= 0){
if(used[to])
break;
else
q.push(to);
}
}
{
int to = v + n;
if(used[to])
break;
else
q.push(to);
}
}
len = mx - 1;
fill(used, used + mx + 1, false);
for(int i = 0; i <= len; i++)
if(!used[i])
dfs(i);
cout << len << '\n';
fill(used, used + len + 1, false);
if(len){
for(int i = 1; i <= len; i++)
cout << pref[i] - pref[i - 1] << ' ';
cout << '\n';
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
there is incorrect sequence |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
there is incorrect sequence |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
there is incorrect sequence |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
there is incorrect sequence |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
there is incorrect sequence |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
there is incorrect sequence |
2 |
Halted |
0 ms |
0 KB |
- |