Submission #93176

# Submission time Handle Problem Language Result Execution time Memory
93176 2019-01-06T19:17:58 Z Vardanyan Nice sequence (IZhO18_sequence) C++14
0 / 100
17 ms 8184 KB
#include <bits/stdc++.h>
using namespace std;
const int N = 1000*1000+5;
int pref[N];
int col[N];
int now = N;
int n,m;
int len;
void dfs(int v){
    col[v] = 1;
    if(v == 0){
        now = -1;
    }
    else{
        pref[v] = now;
        now--;
    }
  if(v-m>=0)  dfs(v-m);
  if(v+n<=len)  dfs(v+n);
}
bool check(int v){
    col[v] = 1;
    for(int i = 0;i<2;i++){
        int to = -1;
        if(i == 0 && v-m>=0) to = v-m;
        else if(i == 1 && v+n<=len) to = v+n;
        if(to == -1) continue;
        if(!col[to]){
            if(check(to)) return true;
        }
        else if(col[to] == 1){
            return true;
        }
    }
    col[v] = 2;
    return false;
}
int main(){
    ios_base::sync_with_stdio(false);
    int t;
    cin>>t;
    while(t--){
        cin>>n>>m;
        int l = min(n,m);
        int r = n+m;
        int as = -1;
        while(l<=r){
            memset(col,0,sizeof col);
            now = N;
            int mid = (l+r)/2;
            len = mid;
            bool f = true;
            for(int i = 1;i<=mid;i++){
                if(!col[i]){
                    if(check(i)){
                        f = false;
                        break;
                    }
                }
            }
            if(!f){
                r = mid-1;
                continue;
            }
            else{
                as = mid;
                l = mid+1;
            }
        }
        if(as == -1){
            cout<<0<<endl;
            continue;
        }
        memset(col,0,sizeof col);
        memset(pref,0,sizeof pref);
        len = as;
        for(int i = 1;i<=n;i++){
            if(!col[i]) dfs(i);
        }
        cout<<as<<endl;
        for(int i = 1;i<=as;i++){
            int x = pref[i]-pref[i-1];
            cout<<x<<" ";
        }
        cout<<endl;
    }
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 8184 KB there is incorrect sequence
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 8184 KB Jury has the better answer : jans = 1, pans = 0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 8184 KB there is incorrect sequence
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 8184 KB there is incorrect sequence
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 8184 KB there is incorrect sequence
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 8184 KB there is incorrect sequence
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 8184 KB there is incorrect sequence
2 Halted 0 ms 0 KB -