QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#823970#6303. InversionEricQian#AC ✓66ms4212kbC++201.1kb2024-12-21 11:15:152024-12-21 11:15:15

Judging History

你现在查看的是最新测评结果

  • [2024-12-21 11:15:15]
  • 评测
  • 测评结果:AC
  • 用时:66ms
  • 内存:4212kb
  • [2024-12-21 11:15:15]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

const int N = 2005;
int n, a[N], pre[N], rv[N];

int ask(int l, int r) {
    if (l == r) return 0;
    int res; printf("? %d %d\n", l, r);
    fflush(stdout);
    scanf("%d", &res);
    return res;
}

int qry(int a, int b) {
    return ask(a, b) ^ ask(a, b - 1) ^ pre[b];
}

void solve(int l, int r) {
    if (l == r) {
        rv[a[r] = 1] = r;
        return;
    }
    solve(l + 1, r);
    int L = 1, R = r - l, res = 0;
    while (L <= R) {
        int mid = (L + R) >> 1;
        int cmp = qry(l, rv[mid]);
        if (cmp) res = mid, L = mid + 1;
        else R = mid - 1;
    }
    rv[a[l] = res + 1] = l;
    for (int i = l + 1; i <= r; i++) {
        if (a[i] >= a[l]) {
            rv[++a[i]] = i;
        }
    }
    for (int i = l + 1; i <= r; i++) {
        if (a[l] > a[i]) pre[i] ^= 1;
    }
}

int main() {
    scanf("%d", &n);
    solve(1, n);
    printf("! ");
    for (int i = 1; i <= n; i++) {
        printf("%d ", a[i]);
    }
    printf("\n");
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3764kb

input:

3
1
0
0
0

output:

? 2 3
? 1 3
? 1 2
? 1 2
! 2 3 1 

result:

ok OK, guesses=4

Test #2:

score: 0
Accepted
time: 27ms
memory: 4000kb

input:

1993
0
0
0
1
0
0
1
1
1
1
1
1
1
1
1
1
1
0
0
0
0
0
1
1
1
1
0
0
1
0
1
0
1
1
1
1
1
1
1
1
1
0
1
1
0
1
1
0
0
1
0
0
0
0
0
0
0
0
1
0
0
1
1
0
0
0
1
1
0
1
1
0
0
0
1
0
1
1
1
1
1
1
1
0
0
1
1
1
1
1
0
1
0
1
1
1
1
0
1
0
0
1
1
1
0
0
0
1
1
1
1
0
0
1
0
1
1
0
1
0
0
0
1
1
0
0
1
0
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
0
1
1
0
1...

output:

? 1992 1993
? 1991 1992
? 1990 1992
? 1990 1991
? 1990 1993
? 1990 1992
? 1989 1992
? 1989 1991
? 1989 1990
? 1989 1993
? 1989 1992
? 1988 1990
? 1988 1989
? 1988 1989
? 1988 1993
? 1988 1992
? 1987 1990
? 1987 1989
? 1987 1988
? 1987 1989
? 1987 1988
? 1986 1989
? 1986 1988
? 1986 1988
? 1986 1987
...

result:

ok OK, guesses=38115

Test #3:

score: 0
Accepted
time: 36ms
memory: 4112kb

input:

1887
0
0
0
1
0
0
1
1
1
1
1
0
0
0
0
1
1
1
1
1
1
0
1
0
0
1
1
1
1
1
0
1
0
1
1
0
1
0
1
0
0
1
0
0
1
1
0
0
0
0
0
0
1
0
0
1
1
0
1
1
0
0
1
1
1
1
0
1
1
0
0
0
1
1
0
0
0
1
0
0
1
1
1
1
1
1
0
1
1
1
0
1
0
1
0
0
0
1
0
0
1
0
0
0
0
1
0
0
0
0
1
1
1
0
1
1
0
1
1
0
0
1
1
1
1
1
1
0
0
1
1
0
1
0
0
0
1
0
1
0
0
1
0
0
1
1
0
0...

output:

? 1886 1887
? 1885 1886
? 1884 1886
? 1884 1885
? 1884 1887
? 1884 1886
? 1883 1886
? 1883 1885
? 1883 1884
? 1883 1887
? 1883 1886
? 1882 1884
? 1882 1883
? 1882 1883
? 1881 1884
? 1881 1883
? 1881 1883
? 1881 1882
? 1881 1882
? 1880 1882
? 1880 1881
? 1880 1883
? 1880 1882
? 1880 1887
? 1880 1886
...

result:

ok OK, guesses=35794

Test #4:

score: 0
Accepted
time: 43ms
memory: 4192kb

input:

1882
0
1
0
1
0
0
0
1
1
1
0
1
1
1
0
0
1
0
0
0
0
0
1
1
0
0
1
0
1
1
1
1
0
1
0
0
1
1
1
0
0
0
1
0
0
1
0
1
0
0
1
1
1
1
0
1
0
1
1
0
1
1
0
1
1
1
0
0
1
0
0
0
1
0
0
0
1
1
0
0
1
0
0
0
1
1
0
0
1
0
1
1
0
1
0
0
0
0
0
0
1
1
1
0
1
0
1
1
1
0
0
1
1
0
1
1
1
1
0
1
1
1
1
1
0
0
0
0
0
0
1
1
0
1
0
0
0
0
1
1
1
0
0
1
1
0
0
1...

output:

? 1881 1882
? 1880 1881
? 1880 1882
? 1880 1881
? 1879 1882
? 1879 1881
? 1879 1880
? 1878 1882
? 1878 1881
? 1878 1881
? 1878 1880
? 1877 1882
? 1877 1881
? 1877 1881
? 1877 1880
? 1876 1878
? 1876 1877
? 1876 1879
? 1876 1878
? 1876 1882
? 1876 1881
? 1875 1876
? 1875 1881
? 1875 1880
? 1875 1877
...

result:

ok OK, guesses=35690

Test #5:

score: 0
Accepted
time: 55ms
memory: 4192kb

input:

1877
0
1
1
1
0
0
0
1
0
1
1
1
0
1
0
0
1
0
1
0
0
0
1
0
1
0
0
1
1
1
0
0
1
1
1
1
1
1
1
0
0
0
0
1
1
1
1
1
0
1
0
0
1
1
1
0
0
0
0
1
0
1
1
0
0
0
1
0
0
1
1
0
1
0
0
1
1
0
1
1
1
1
0
1
0
1
0
0
0
1
0
0
0
1
0
1
1
1
0
1
1
1
1
0
1
0
0
1
1
1
0
1
1
0
1
1
0
0
1
0
0
1
1
1
0
0
0
1
0
0
1
1
1
1
1
0
1
1
1
1
0
1
0
0
0
0
1
0...

output:

? 1876 1877
? 1875 1876
? 1875 1877
? 1875 1876
? 1874 1875
? 1874 1876
? 1874 1875
? 1873 1874
? 1873 1875
? 1873 1874
? 1873 1877
? 1873 1876
? 1872 1875
? 1872 1874
? 1872 1876
? 1872 1875
? 1872 1874
? 1872 1873
? 1871 1874
? 1871 1873
? 1871 1876
? 1871 1875
? 1870 1874
? 1870 1873
? 1870 1876
...

result:

ok OK, guesses=35636

Test #6:

score: 0
Accepted
time: 44ms
memory: 4040kb

input:

1871
0
1
0
1
1
0
0
0
1
1
0
1
0
1
1
0
1
0
0
1
0
0
1
1
1
0
0
0
1
0
1
0
0
0
0
0
0
1
0
0
0
1
1
1
1
0
1
0
1
1
0
1
1
1
0
0
0
1
1
0
1
0
1
0
1
0
0
0
0
1
0
1
1
1
0
0
0
0
1
0
0
0
1
1
0
1
1
0
0
1
0
1
0
0
1
1
0
1
1
0
0
1
0
0
1
1
1
0
0
1
1
1
1
1
1
1
1
1
1
1
0
1
0
1
0
1
1
0
0
1
0
1
0
1
0
0
1
0
1
0
0
0
0
0
0
1
1
0...

output:

? 1870 1871
? 1869 1870
? 1869 1871
? 1869 1870
? 1868 1871
? 1868 1870
? 1868 1870
? 1868 1869
? 1867 1868
? 1867 1871
? 1867 1870
? 1866 1867
? 1866 1871
? 1866 1870
? 1865 1867
? 1865 1866
? 1865 1870
? 1865 1869
? 1865 1868
? 1865 1867
? 1864 1867
? 1864 1866
? 1864 1871
? 1864 1870
? 1864 1869
...

result:

ok OK, guesses=35400

Test #7:

score: 0
Accepted
time: 24ms
memory: 4148kb

input:

1994
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0...

output:

? 1993 1994
? 1992 1993
? 1991 1993
? 1991 1992
? 1991 1992
? 1990 1992
? 1990 1991
? 1990 1991
? 1989 1992
? 1989 1991
? 1989 1990
? 1988 1991
? 1988 1990
? 1988 1989
? 1987 1991
? 1987 1990
? 1987 1989
? 1987 1988
? 1987 1988
? 1986 1990
? 1986 1989
? 1986 1988
? 1986 1987
? 1986 1987
? 1985 1990
...

result:

ok OK, guesses=33815

Test #8:

score: 0
Accepted
time: 25ms
memory: 4124kb

input:

1990
0
1
0
1
0
1
1
0
1
1
0
1
1
1
1
0
1
1
0
0
1
0
1
1
0
0
1
1
0
1
1
0
1
0
1
0
0
1
0
0
0
0
0
1
0
1
0
1
0
0
0
0
0
0
0
1
1
0
0
1
1
0
1
0
0
1
0
1
0
1
0
1
0
0
1
0
1
1
0
0
0
1
0
1
0
1
1
0
1
1
0
0
1
1
0
0
0
1
0
1
0
0
0
0
0
1
1
0
0
0
1
1
0
0
0
1
0
1
0
1
1
0
1
0
0
1
0
0
1
1
1
1
0
0
0
1
1
0
1
1
1
0
0
1
0
0
0
0...

output:

? 1989 1990
? 1988 1989
? 1988 1990
? 1988 1989
? 1987 1990
? 1987 1989
? 1987 1989
? 1987 1988
? 1986 1989
? 1986 1988
? 1986 1990
? 1986 1989
? 1985 1986
? 1985 1990
? 1985 1989
? 1985 1988
? 1985 1987
? 1984 1986
? 1984 1985
? 1984 1987
? 1984 1986
? 1984 1989
? 1984 1988
? 1983 1986
? 1983 1985
...

result:

ok OK, guesses=37093

Test #9:

score: 0
Accepted
time: 31ms
memory: 4016kb

input:

1981
0
1
0
1
1
0
0
0
1
1
1
0
1
0
1
1
1
1
0
1
1
1
1
0
0
0
1
1
0
0
1
0
1
0
1
0
1
0
1
0
1
0
0
1
0
0
1
0
0
1
1
0
0
0
0
0
1
1
1
0
1
0
1
0
0
1
0
1
0
0
0
0
1
1
0
1
0
1
0
0
0
0
0
1
0
0
0
1
1
0
1
0
0
0
1
1
0
1
0
1
0
1
0
0
0
1
0
0
0
0
0
0
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
1
0
1
0
0
0
1
1
1
1
1
0
1
0
1
1
0
1
1
0
1...

output:

? 1980 1981
? 1979 1980
? 1979 1981
? 1979 1980
? 1978 1981
? 1978 1980
? 1978 1980
? 1978 1979
? 1977 1978
? 1977 1981
? 1977 1980
? 1977 1979
? 1977 1978
? 1976 1981
? 1976 1980
? 1976 1979
? 1976 1978
? 1976 1977
? 1975 1981
? 1975 1980
? 1975 1980
? 1975 1979
? 1974 1981
? 1974 1980
? 1974 1980
...

result:

ok OK, guesses=37538

Test #10:

score: 0
Accepted
time: 39ms
memory: 4208kb

input:

1988
0
1
1
1
0
0
0
1
1
1
0
0
0
0
0
1
0
1
1
1
1
1
1
0
1
0
1
0
0
0
1
0
0
1
0
0
1
1
0
1
0
1
1
0
1
0
1
1
0
0
1
0
0
1
1
0
0
1
0
1
1
1
0
0
1
1
0
1
0
0
1
1
1
0
1
1
0
1
0
1
1
1
1
0
0
0
1
1
1
1
0
0
0
0
1
0
0
1
1
1
1
1
1
0
1
0
0
0
1
1
1
0
1
0
0
1
1
0
1
1
1
1
0
0
0
1
1
1
0
0
0
0
1
0
0
0
0
0
0
0
1
0
1
1
1
0
1
1...

output:

? 1987 1988
? 1986 1987
? 1986 1988
? 1986 1987
? 1985 1986
? 1985 1987
? 1985 1986
? 1984 1985
? 1984 1986
? 1984 1985
? 1983 1984
? 1983 1987
? 1983 1986
? 1983 1985
? 1983 1984
? 1982 1983
? 1982 1986
? 1982 1985
? 1982 1988
? 1982 1987
? 1981 1984
? 1981 1983
? 1981 1982
? 1981 1988
? 1981 1987
...

result:

ok OK, guesses=37811

Test #11:

score: 0
Accepted
time: 54ms
memory: 4132kb

input:

1991
0
1
0
1
0
0
0
0
1
1
0
1
0
0
1
0
0
0
0
1
1
0
0
0
1
1
0
0
1
0
0
0
0
0
1
1
1
0
0
0
1
0
1
1
0
1
0
0
0
0
0
0
1
0
0
1
1
0
1
0
0
1
0
1
0
1
1
0
1
1
1
1
1
1
1
1
1
1
0
0
1
0
1
1
0
1
0
1
1
0
0
0
0
1
1
0
1
1
0
1
0
0
1
1
1
0
0
0
0
1
0
0
1
0
0
0
1
1
0
0
1
0
0
1
0
1
1
0
1
1
1
1
1
1
1
0
0
0
1
0
1
0
1
0
1
0
0
1...

output:

? 1990 1991
? 1989 1990
? 1989 1991
? 1989 1990
? 1988 1991
? 1988 1990
? 1988 1989
? 1987 1991
? 1987 1990
? 1987 1988
? 1987 1989
? 1987 1988
? 1986 1988
? 1986 1987
? 1986 1989
? 1986 1988
? 1985 1988
? 1985 1987
? 1985 1990
? 1985 1989
? 1985 1991
? 1985 1990
? 1984 1988
? 1984 1987
? 1984 1991
...

result:

ok OK, guesses=38019

Test #12:

score: 0
Accepted
time: 31ms
memory: 4212kb

input:

1996
1
0
0
0
0
1
0
1
0
1
0
0
0
0
0
0
1
0
1
0
0
1
0
1
0
0
0
1
1
1
1
1
1
1
1
0
1
1
0
1
1
1
1
0
1
0
1
1
1
1
0
0
1
0
0
1
0
0
0
0
0
1
0
0
0
0
1
0
1
1
0
1
1
0
1
0
0
0
0
1
0
1
1
1
1
0
1
1
0
0
1
0
0
1
1
1
1
0
0
0
1
1
1
0
0
0
0
0
1
1
1
0
1
1
1
0
1
0
1
0
0
0
0
1
1
1
0
1
1
0
0
1
0
1
1
0
1
0
0
1
1
1
0
1
1
0
0
1...

output:

? 1995 1996
? 1994 1996
? 1994 1995
? 1994 1995
? 1993 1994
? 1993 1996
? 1993 1995
? 1992 1993
? 1992 1994
? 1992 1993
? 1992 1995
? 1992 1994
? 1991 1994
? 1991 1993
? 1991 1992
? 1990 1994
? 1990 1993
? 1990 1992
? 1990 1991
? 1990 1995
? 1990 1994
? 1989 1991
? 1989 1990
? 1989 1993
? 1989 1992
...

result:

ok OK, guesses=38223

Test #13:

score: 0
Accepted
time: 16ms
memory: 4212kb

input:

1992
1
1
1
1
1
1
1
0
1
1
1
1
0
1
1
1
1
0
0
1
1
1
0
0
1
1
1
1
0
0
1
1
1
1
1
0
0
1
1
1
1
1
1
0
1
1
1
1
1
1
0
1
1
1
1
0
1
0
0
1
1
1
0
1
0
0
1
1
1
0
0
0
0
1
1
1
0
0
0
0
1
1
1
1
0
1
0
0
1
1
1
1
1
0
1
0
0
1
1
1
1
1
1
1
0
0
1
1
1
1
1
1
1
0
0
1
1
1
1
0
1
1
1
0
1
1
1
1
0
1
1
1
0
1
1
1
1
0
0
1
1
0
1
1
1
1
0
0...

output:

? 1991 1992
? 1990 1992
? 1990 1991
? 1990 1991
? 1989 1991
? 1989 1990
? 1989 1990
? 1988 1991
? 1988 1990
? 1988 1990
? 1988 1989
? 1988 1989
? 1987 1990
? 1987 1989
? 1987 1989
? 1987 1988
? 1987 1988
? 1986 1990
? 1986 1989
? 1986 1988
? 1986 1987
? 1986 1987
? 1985 1989
? 1985 1988
? 1985 1987
...

result:

ok OK, guesses=37739

Test #14:

score: 0
Accepted
time: 34ms
memory: 4052kb

input:

1988
0
1
0
1
1
0
0
0
1
0
0
1
1
1
0
0
0
1
1
0
0
0
1
0
0
0
0
0
0
1
0
1
1
1
0
0
1
0
0
1
0
1
1
0
0
0
0
1
0
0
1
1
0
0
0
0
1
1
0
0
1
1
0
0
1
1
1
0
0
0
1
0
0
1
0
0
1
1
1
0
0
1
1
1
1
0
1
0
1
0
1
1
1
0
0
0
0
0
1
1
1
1
0
1
0
1
0
1
0
0
1
1
0
0
0
0
1
1
1
0
0
1
0
0
0
1
0
0
1
1
0
0
0
1
0
1
0
1
1
1
0
1
0
0
1
0
1
0...

output:

? 1987 1988
? 1986 1987
? 1986 1988
? 1986 1987
? 1985 1988
? 1985 1987
? 1985 1987
? 1985 1986
? 1984 1985
? 1984 1988
? 1984 1987
? 1984 1986
? 1984 1985
? 1983 1988
? 1983 1987
? 1983 1984
? 1982 1988
? 1982 1987
? 1982 1987
? 1982 1986
? 1982 1985
? 1982 1984
? 1981 1988
? 1981 1987
? 1981 1982
...

result:

ok OK, guesses=37772

Test #15:

score: 0
Accepted
time: 53ms
memory: 4148kb

input:

1983
0
1
1
1
1
1
1
0
0
0
1
1
1
1
0
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
0
1
0
0
0
0
0
0
1
0
1
0
1
1
1
1
0
0
1
0
0
0
1
0
0
1
0
1
0
0
1
1
1
1
0
1
1
1
0
1
0
1
0
1
1
1
1
1
1
1
0
0
0
0
1
0
1
0
0
0
0
1
0
1
0
0
1
0
1
0
1
1
1
0
0
0
0
0
0
1
1
1
0
1
0
0
1
1
1
0
1
1
1
1
0
1
0
0
1
0
0
0
1
1
1
1
0
0
0
1
1
0
1...

output:

? 1982 1983
? 1981 1982
? 1981 1983
? 1981 1982
? 1980 1981
? 1980 1983
? 1980 1982
? 1979 1981
? 1979 1980
? 1979 1980
? 1978 1979
? 1978 1980
? 1978 1979
? 1977 1979
? 1977 1978
? 1977 1982
? 1977 1981
? 1977 1981
? 1977 1980
? 1976 1979
? 1976 1978
? 1976 1980
? 1976 1979
? 1976 1978
? 1976 1977
...

result:

ok OK, guesses=37789

Test #16:

score: 0
Accepted
time: 42ms
memory: 4056kb

input:

1990
1
1
1
1
1
0
0
1
1
0
1
1
0
0
0
1
1
0
1
0
1
0
1
0
0
1
0
0
0
0
0
0
1
1
0
0
0
1
1
0
0
0
1
0
1
0
0
1
0
0
0
0
0
0
0
1
0
0
1
0
0
0
0
0
1
1
0
1
1
1
1
1
0
1
1
1
1
1
0
1
0
1
1
1
0
0
0
1
0
0
1
1
0
0
1
0
1
1
1
1
0
1
0
1
1
1
0
1
1
0
0
0
1
0
0
0
1
0
0
1
1
0
0
0
0
0
0
1
1
0
0
1
1
1
1
0
0
1
0
0
0
1
0
0
0
0
0
1...

output:

? 1989 1990
? 1988 1990
? 1988 1989
? 1988 1989
? 1987 1989
? 1987 1988
? 1987 1990
? 1987 1989
? 1986 1987
? 1986 1989
? 1986 1988
? 1985 1986
? 1985 1989
? 1985 1988
? 1985 1988
? 1985 1987
? 1984 1986
? 1984 1985
? 1984 1990
? 1984 1989
? 1983 1986
? 1983 1985
? 1983 1990
? 1983 1989
? 1983 1984
...

result:

ok OK, guesses=38024

Test #17:

score: 0
Accepted
time: 66ms
memory: 4140kb

input:

1989
1
0
0
0
1
0
1
1
0
1
0
0
1
1
1
1
1
1
0
0
1
0
0
1
1
1
1
1
1
0
1
1
1
1
0
1
1
1
0
1
1
0
1
0
1
0
1
0
0
1
0
1
0
0
1
0
0
1
1
1
0
0
1
1
1
1
1
1
0
1
1
0
0
1
0
0
1
1
0
0
1
0
1
0
0
1
1
0
1
1
1
0
0
1
1
1
1
0
0
0
0
0
1
1
0
0
0
1
0
1
1
1
0
0
1
0
1
0
0
1
0
0
0
0
0
0
1
1
0
0
0
1
0
0
0
1
0
0
0
0
0
1
0
1
0
1
1
1...

output:

? 1988 1989
? 1987 1989
? 1987 1988
? 1987 1988
? 1986 1987
? 1986 1988
? 1986 1987
? 1985 1987
? 1985 1986
? 1985 1989
? 1985 1988
? 1984 1987
? 1984 1986
? 1984 1985
? 1984 1989
? 1984 1988
? 1983 1984
? 1983 1988
? 1983 1987
? 1983 1987
? 1983 1986
? 1982 1983
? 1982 1989
? 1982 1988
? 1982 1985
...

result:

ok OK, guesses=38022

Test #18:

score: 0
Accepted
time: 64ms
memory: 4128kb

input:

1998
1
1
1
1
1
0
0
1
0
0
1
1
1
1
1
0
0
0
0
1
1
1
1
0
0
0
1
0
0
1
0
0
1
1
0
0
1
0
0
1
1
1
1
1
1
0
1
1
0
1
0
1
1
1
1
1
0
1
1
0
0
0
1
0
0
0
0
1
1
1
0
1
1
0
1
1
1
1
1
0
0
1
1
0
1
1
0
1
1
1
1
0
0
1
1
0
0
1
0
1
1
1
0
0
1
0
1
1
1
1
1
1
0
1
1
1
1
0
0
1
1
1
1
0
0
1
1
0
0
1
0
0
0
0
1
0
1
0
1
0
0
1
0
1
0
0
1
0...

output:

? 1997 1998
? 1996 1998
? 1996 1997
? 1996 1997
? 1995 1997
? 1995 1996
? 1995 1998
? 1995 1997
? 1994 1995
? 1994 1998
? 1994 1997
? 1993 1995
? 1993 1994
? 1993 1994
? 1993 1998
? 1993 1997
? 1992 1998
? 1992 1997
? 1992 1997
? 1992 1996
? 1992 1995
? 1992 1994
? 1991 1992
? 1991 1997
? 1991 1996
...

result:

ok OK, guesses=38255

Test #19:

score: 0
Accepted
time: 1ms
memory: 3948kb

input:

1

output:

! 1 

result:

ok OK, guesses=0

Test #20:

score: 0
Accepted
time: 1ms
memory: 3800kb

input:

2
0

output:

? 1 2
! 1 2 

result:

ok OK, guesses=1

Test #21:

score: 0
Accepted
time: 0ms
memory: 3880kb

input:

2
1

output:

? 1 2
! 2 1 

result:

ok OK, guesses=1

Test #22:

score: 0
Accepted
time: 39ms
memory: 4084kb

input:

1997
0
1
1
1
0
1
0
1
1
1
1
0
1
0
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
0
1
0
1
1
1
1
1
1
1
1
1
0
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
0
1
0
1
1
1
1
1
1
1
1
1
1...

output:

? 1996 1997
? 1995 1996
? 1995 1997
? 1995 1996
? 1994 1995
? 1994 1996
? 1994 1995
? 1993 1996
? 1993 1995
? 1993 1995
? 1993 1994
? 1992 1993
? 1992 1994
? 1992 1993
? 1991 1996
? 1991 1995
? 1991 1992
? 1991 1994
? 1991 1993
? 1990 1996
? 1990 1995
? 1990 1994
? 1990 1993
? 1990 1992
? 1990 1991
...

result:

ok OK, guesses=35867

Test #23:

score: 0
Accepted
time: 61ms
memory: 4136kb

input:

1998
1
1
0
1
1
1
1
1
1
1
0
1
1
1
1
1
0
1
0
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
0
1
0
1
1
1
1
1
1
1
1
1
0
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
0
1...

output:

? 1997 1998
? 1996 1998
? 1996 1997
? 1995 1998
? 1995 1997
? 1995 1997
? 1995 1996
? 1994 1998
? 1994 1997
? 1994 1996
? 1994 1995
? 1993 1998
? 1993 1997
? 1993 1994
? 1993 1996
? 1993 1995
? 1992 1993
? 1992 1994
? 1992 1993
? 1991 1993
? 1991 1992
? 1991 1994
? 1991 1993
? 1991 1996
? 1991 1995
...

result:

ok OK, guesses=35888

Test #24:

score: 0
Accepted
time: 47ms
memory: 4128kb

input:

1999
0
1
1
1
0
1
0
1
1
1
1
0
1
0
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
0
1
0
1
1
1
1
1
1
1
1
1
0
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
0
1
0
1
1
1
1
1
1
1
1
1
1...

output:

? 1998 1999
? 1997 1998
? 1997 1999
? 1997 1998
? 1996 1997
? 1996 1998
? 1996 1997
? 1995 1998
? 1995 1997
? 1995 1997
? 1995 1996
? 1994 1995
? 1994 1996
? 1994 1995
? 1993 1998
? 1993 1997
? 1993 1994
? 1993 1996
? 1993 1995
? 1992 1998
? 1992 1997
? 1992 1996
? 1992 1995
? 1992 1994
? 1992 1993
...

result:

ok OK, guesses=35907

Test #25:

score: 0
Accepted
time: 32ms
memory: 4180kb

input:

2000
1
1
0
1
1
1
1
1
1
1
0
1
1
1
1
1
0
1
0
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
0
1
0
1
1
1
1
1
1
1
1
1
0
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
1
0
1
0
1...

output:

? 1999 2000
? 1998 2000
? 1998 1999
? 1997 2000
? 1997 1999
? 1997 1999
? 1997 1998
? 1996 2000
? 1996 1999
? 1996 1998
? 1996 1997
? 1995 2000
? 1995 1999
? 1995 1996
? 1995 1998
? 1995 1997
? 1994 1995
? 1994 1996
? 1994 1995
? 1993 1995
? 1993 1994
? 1993 1996
? 1993 1995
? 1993 1998
? 1993 1997
...

result:

ok OK, guesses=35928