QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#506502#2833. Hamiltonliyixin0514AC ✓16ms19572kbC++141.1kb2024-08-05 18:21:552024-08-05 18:21:55

Judging History

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

  • [2024-08-05 18:21:55]
  • 评测
  • 测评结果:AC
  • 用时:16ms
  • 内存:19572kb
  • [2024-08-05 18:21:55]
  • 提交

answer

#include<bits/stdc++.h>
// #define LOCAL
#define sf scanf
#define pf printf
#define rep(x,y,z) for(int x=y;x<=z;x++)
using namespace std;
typedef long long ll;
const int N=2e3+5;
int n;
int c[N][N];
int a[N],b[N];
int pos=2;
int read(){
    char ch=getchar();
    while(ch!='0'&&ch!='1') ch=getchar();
    return ch-'0';
}
void insert(int x,int y,int z){
    a[x]=y,a[y]=z;
    b[y]=x,b[z]=y;
}
int main(){
    #ifdef LOCAL
    freopen("in.txt","r",stdin);
    freopen("my.out","w",stdout);
    #endif
    while(cin>>n){
        rep(i,1,n) rep(j,1,n) c[i][j]=read();
        a[1]=2,a[2]=1;
        b[1]=2,b[2]=1;
        pos=1;
        rep(i,3,n){
            if(c[pos][i]==c[pos][b[pos]]){
                insert(pos,i,a[pos]);
            }else{
                insert(b[pos],i,pos);
            }
            rep(j,1,i){
                if(c[j][b[j]]!=c[j][a[j]]){
                    pos= j;break;
                }
            }
        }
        rep(i,1,n) {
            pf("%d ",pos);
            pos=a[pos];
        }
        pf("\n");
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3816kb

input:

3
001
000
100
4
0000
0000
0000
0000

output:

1 2 3 
1 4 3 2 

result:

ok 2 cases.

Test #2:

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

input:

3
000
000
000
3
010
100
000
3
011
100
100
3
011
101
110

output:

1 3 2 
1 2 3 
2 1 3 
1 3 2 

result:

ok 4 cases.

Test #3:

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

input:

4
0000
0000
0000
0000
4
0000
0001
0000
0100
4
0100
1010
0100
0000
4
0111
1000
1000
1000
4
0010
0011
1101
0110
4
0111
1011
1100
1100
4
0111
1011
1101
1110
4
0000
0011
0101
0110
4
0101
1010
0100
1000
4
0011
0011
1100
1100
4
0010
0001
1000
0100

output:

1 4 3 2 
1 4 3 2 
2 3 1 4 
3 2 4 1 
2 3 4 1 
3 2 1 4 
1 4 3 2 
3 2 4 1 
3 4 1 2 
1 4 2 3 
1 2 3 4 

result:

ok 11 cases.

Test #4:

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

input:

5
00000
00000
00000
00000
00000
5
00001
00000
00000
00000
10000
5
00010
00010
00000
11000
00000
5
00000
00001
00001
00001
01110
5
00001
00001
00001
00001
11110
5
00101
00100
11011
00100
10100
5
01111
10011
10000
11000
11000
5
00011
00011
00011
11101
11110
5
01101
10111
11001
01001
11110
5
00111
0011...

output:

1 5 4 3 2 
1 4 3 2 5 
2 4 5 1 3 
4 3 2 1 5 
1 4 3 2 5 
4 1 2 5 3 
4 2 1 5 3 
2 4 1 5 3 
1 3 2 4 5 
1 5 4 2 3 
1 5 4 3 2 
4 2 1 5 3 
3 5 4 2 1 
1 3 4 2 5 
4 1 5 3 2 
4 2 1 5 3 
1 4 3 2 5 
2 4 5 1 3 
3 1 4 5 2 
2 3 1 4 5 
4 1 5 3 2 
1 5 3 2 4 
4 5 2 3 1 
2 5 3 4 1 
3 4 1 2 5 
1 4 2 3 5 
4 3 2 1 5 
1 2...

result:

ok 34 cases.

Test #5:

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

input:

6
000000
000000
000000
000000
000000
000000
6
000000
000000
000001
000000
000000
001000
6
010000
100100
000000
010000
000000
000000
6
000100
000000
000100
101010
000100
000000
6
000100
000000
000100
101011
000100
000100
6
001000
001000
110111
001000
001000
001000
6
001100
000100
100100
111011
000100...

output:

1 6 5 4 3 2 
1 6 5 4 3 2 
2 6 3 1 4 5 
4 6 5 1 3 2 
5 1 3 2 6 4 
5 3 6 4 1 2 
1 4 5 2 3 6 
5 1 3 2 6 4 
5 1 3 6 2 4 
4 1 6 5 2 3 
4 1 6 5 2 3 
4 2 3 5 6 1 
1 5 3 2 4 6 
5 4 3 2 1 6 
1 6 5 4 3 2 
1 6 5 4 3 2 
1 5 3 2 4 6 
1 4 3 2 5 6 
1 6 5 4 2 3 
5 3 2 1 4 6 
3 2 1 5 4 6 
5 3 2 1 6 4 
5 1 3 2 6 4 
1...

result:

ok 156 cases.

Test #6:

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

input:

7
0000010
0001011
0001010
0110100
0001001
1110001
0100110
7
0101001
1011000
0101100
1110010
0010010
0001100
1000000
7
0001111
0011001
0100100
1100101
1011000
1000000
1101000
7
0111111
1011101
1101001
1110010
1100010
1001101
1110010
7
0010111
0010001
1101010
0010000
1000011
1010100
1100100
7
0001010
...

output:

6 5 3 2 1 4 7 
3 4 5 1 6 2 7 
3 2 4 1 6 5 7 
4 3 2 1 5 6 7 
3 7 4 1 2 5 6 
5 1 7 6 3 2 4 
3 7 5 4 6 2 1 
2 7 4 1 6 5 3 
1 7 4 5 2 3 6 
5 3 2 6 7 4 1 
6 5 3 4 7 2 1 
6 1 7 4 5 2 3 
5 2 3 6 7 4 1 
6 2 7 5 3 1 4 
6 4 1 3 7 5 2 
3 2 1 4 6 5 7 
4 6 1 5 2 7 3 
4 6 2 7 5 1 3 
5 7 6 4 2 3 1 
6 4 1 2 7 5 3 
...

result:

ok 286 cases.

Test #7:

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

input:

5
01000
10100
01010
00100
00000
9
001101110
001010001
110100110
101010000
010100011
100000000
101000000
101010001
010010010
4
0000
0011
0101
0110
8
00100101
00101100
11000011
00001111
01010101
11011000
00110000
10111000
9
000000001
001101000
010000100
010000111
000000000
010000111
001101010
00010110...

output:

2 5 3 1 4 
3 1 4 5 8 6 2 7 9 
3 2 4 1 
2 8 6 3 4 1 5 7 
8 6 2 4 9 7 1 3 5 
1 4 2 3 
5 1 4 6 2 3 
5 3 1 4 2 6 
3 5 6 2 1 4 7 
5 1 6 7 4 2 3 
9 8 10 6 7 1 5 2 3 4 
8 9 10 1 7 4 2 3 5 6 
1 6 3 2 4 5 
7 5 3 1 8 4 6 2 
8 5 3 9 6 7 1 4 2 
1 2 3 
1 3 2 
3 6 4 1 5 2 
6 4 2 3 7 5 1 
1 2 3 
1 2 3 
2 4 1 3 5 
...

result:

ok 322 cases.

Test #8:

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

input:

10
0010001000
0010011001
1101101001
0010111000
0011000110
0101001100
1111010001
0000110011
0000100101
0110001110
10
0000000010
0000001001
0000001101
0000100000
0001010111
0000101011
0110010100
0010101000
1000110000
0110110000
10
0110010111
1011111110
1100101010
0100001101
0110001111
1100001010
01111...

output:

8 1 2 5 7 9 10 3 4 6 
7 10 9 8 6 4 3 2 1 5 
9 5 3 2 8 10 6 4 1 7 
5 3 7 9 6 2 4 1 8 10 
9 7 3 8 10 6 4 1 2 5 
8 3 9 10 7 6 4 1 2 5 
2 8 7 4 1 3 5 9 6 10 
7 6 1 3 4 9 2 8 5 10 
7 9 2 10 8 6 4 1 3 5 
1 2 3 6 9 5 7 4 8 10 
5 3 8 2 7 4 6 9 1 10 
9 5 6 10 8 1 7 4 2 3 
8 6 1 2 3 5 7 4 9 10 
9 6 1 4 2 5 7 ...

result:

ok 200 cases.

Test #9:

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

input:

10
0110101100
1010100111
1101100101
0010111010
1111001010
0001000000
1001100111
1110001001
0101101000
0110001100
10
0111110111
1001111100
1001100100
1110101111
1111001010
1100001000
0101110100
1111001010
1001100100
1001000000
10
0100000111
1011111001
0100001111
0100100110
0101011100
0100100110
01101...

output:

3 6 2 4 8 9 5 1 7 10 
5 1 3 4 2 6 7 8 9 10 
6 2 5 7 3 8 1 9 10 4 
8 7 1 6 4 10 3 9 5 2 
8 3 7 5 1 6 9 4 10 2 
3 10 8 4 6 9 7 1 5 2 
9 7 8 10 6 2 1 4 5 3 
8 6 7 2 3 1 4 9 5 10 
4 10 6 3 5 7 2 8 1 9 
9 5 3 2 4 1 8 10 6 7 
8 7 4 5 2 10 9 6 3 1 
9 4 5 7 10 8 3 2 1 6 
7 2 1 10 9 6 8 5 3 4 
2 3 4 7 5 8 6 ...

result:

ok 200 cases.

Test #10:

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

input:

20
00011111000111100010
00100111111000000010
01011011101000100111
10100010000100000010
10100100000010101101
11001001010010000111
11110000010000111001
11100100111000010101
01100001011101100010
01000111100111011001
01100001100111111111
10010000111001010000
10001100011001001000
10000000111110111010
101...

output:

18 19 20 8 6 1 5 3 4 7 2 11 12 10 13 14 9 15 16 17 
18 15 11 14 10 8 7 9 12 17 19 16 13 5 2 3 4 6 1 
21 6 18 11 17 4 16 12 15 10 9 13 14 20 22 2 8 1 7 5 3 19 
7 4 6 8 9 11 12 1 2 3 5 10 13 
9 6 4 24 27 3 23 16 22 19 14 11 8 5 2 1 7 13 18 20 17 21 25 15 26 28 12 29 10 30 
20 13 18 21 22 15 14 10 2 9 ...

result:

ok 72 cases.

Test #11:

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

input:

59
01110100011001000100111000110110010001011111001011011101100
10001011111001111100111111100010111011100101001100001000101
10000011101010011100111011000001101110001100001110110101001
10001100100110101001000000101101101110001110111001110001101
010101010101101111110011111000100101111111101001111100111...

output:

53 54 47 24 21 17 12 16 13 6 11 10 9 5 3 2 4 7 1 15 14 19 8 20 22 23 25 18 30 32 46 52 51 55 48 56 45 57 39 58 44 59 38 35 36 31 33 27 34 37 40 29 41 28 42 26 43 50 49 
61 47 43 41 39 36 34 23 31 28 25 26 17 4 5 8 10 12 13 18 21 2 22 33 35 37 42 44 40 45 58 62 57 50 56 46 55 51 54 52 38 30 29 27 24 ...

result:

ok 29 cases.

Test #12:

score: 0
Accepted
time: 2ms
memory: 6152kb

input:

160
0010110100011110110110110001100110111000000100001100110101001011100101011100011100111011011011010011010110101100000011111010110111001011001100010000101111001101
000011011110000111010100011011010001001101001100111010101101001011001101001001000001011010001101100111011110110101111010101100000101001...

output:

152 153 148 145 146 139 123 117 112 95 93 92 87 84 71 69 65 44 64 52 63 61 55 50 43 49 47 41 36 33 19 3 4 5 8 11 17 25 27 29 24 30 35 39 46 48 51 53 54 56 45 57 42 58 34 59 62 66 78 81 76 86 89 85 90 98 102 104 110 118 120 122 130 132 140 147 150 143 158 157 154 151 136 133 124 129 127 115 113 101 9...

result:

ok 14 cases.

Test #13:

score: 0
Accepted
time: 3ms
memory: 7244kb

input:

438
01000100111101110010100101010001000101100011101011001001011110011100000110001001100101100101110011110111001101001101100111110010011001000110100110101001001101110001110011101010100010110100001011110011001000000001111111011001001010011101110010110111011111100011111101101001101010101010110000000111...

output:

436 437 431 422 430 428 426 419 406 412 409 295 405 403 324 402 326 401 328 400 398 395 392 390 332 389 386 385 383 338 382 379 375 378 374 370 368 343 367 364 348 363 361 359 347 358 356 355 351 352 345 340 341 337 335 329 300 298 292 291 289 288 286 280 278 264 256 253 248 244 225 222 208 198 203 ...

result:

ok 7 cases.

Test #14:

score: 0
Accepted
time: 9ms
memory: 14588kb

input:

1227
0100010000101001111110111010100100001100101111001011101010010000100111110110000001101101000101010011000101100110010011010100010011111000101101011001010111010010101001100100011000100000101011011011110101010011011110111101110010100010101111010101011001100001000110011101101010010011110010011011100...

output:

1219 1203 1201 1199 1197 1193 1144 1141 1138 1135 1136 1126 1132 1129 1116 1122 1120 1115 1111 1107 1095 1102 1090 1101 1096 1097 1087 1085 1070 1067 1066 1050 1065 1061 1060 1056 1055 1053 1046 1049 1047 1037 1032 1030 1025 1027 1024 1022 1014 1006 1004 992 991 989 981 988 985 984 982 975 963 939 9...

result:

ok 2 cases.

Test #15:

score: 0
Accepted
time: 9ms
memory: 12848kb

input:

1078
0111011100111011000000110100010011001100100101011100111000110001110111110010111010110111010110001010100111101001110111010010000001000100110000000010000010111010101000000110101011011011000001100000011111010001010001101111011110111110000110111111111111101100110100011001110110111011111001110010110...

output:

1065 1078 1076 1073 1070 1071 1061 1062 1057 1052 1056 1054 1051 1048 1038 1047 1041 1033 1030 1024 1018 1015 1010 1006 1003 996 1002 1000 998 992 988 983 982 978 974 972 969 968 929 967 964 962 959 956 952 936 951 948 938 947 945 942 943 935 932 930 912 920 918 915 897 860 896 886 895 893 888 889 8...

result:

ok 2 cases.

Test #16:

score: 0
Accepted
time: 4ms
memory: 15536kb

input:

1310
0110101010101111001001001110010101000100000000011001001110111010011000110110010000001110111100110100110110110000011001000101100100000011011111011100010001101111001100100000011100111111101101001011000101000011100101111011100101011111000100101110011110001101110110100111101101011000000000101000101...

output:

1308 1307 1304 1298 1290 1289 1287 1285 1263 1281 1279 1267 1278 1276 1274 1272 1265 1260 1257 1254 1255 1246 1238 1229 1197 1228 1225 1222 1221 1206 1220 1208 1219 1216 1213 1211 1204 1191 1203 1200 1198 1188 1174 1177 1175 1171 1169 1152 1168 1147 1167 1164 1163 1161 1160 1153 1154 1149 1146 1143 ...

result:

ok 2 cases.

Test #17:

score: 0
Accepted
time: 3ms
memory: 17452kb

input:

1542
0000100001001001100011001101100001110111010111001110111110011011001000110010001111000000100011101001000100000001111001110100110101101111000011100010000100000111010001010110101110000001000001110100101111100001110010111000111001010111011100100100111011010101001100100101110110011000001011001000011...

output:

1529 1524 1522 1513 1512 1509 1507 1504 1494 1500 1497 1488 1475 1472 1470 1459 1447 1445 1436 1444 1442 1439 1435 1433 1432 1428 1429 1422 1420 1382 1407 1400 1401 1394 1391 1387 1386 1384 1377 1371 1360 1368 1363 1361 1355 1350 1354 1352 1336 1333 1330 1329 1326 1318 1322 1319 1315 1305 1314 1312 ...

result:

ok 2 cases.

Test #18:

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

input:

2000
0101010000001001011001110100110110001010001110110101101100010010011100000111001100000000110111011111100001110001111011101101110010100100001001110010001111011110011011010000100001011100000000110011000110010100101010110100001010101001111101011001110011010001100110000110101110000001000101001101010...

output:

1995 1992 1968 1991 1981 1990 1987 1980 1986 1984 1977 1965 1961 1962 1942 1937 1924 1919 1886 1884 1883 1880 1879 1873 1878 1875 1859 1872 1869 1865 1860 1846 1844 1840 1839 1836 1830 1824 1829 1827 1817 1818 1809 1806 1803 1794 1795 1777 1791 1789 1787 1782 1786 1781 1778 1766 1761 1759 1754 1727 ...

result:

ok 1 cases.

Test #19:

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

input:

2000
0100001100010101000111011110110000001010100001111010011110111010011101000001100111011101101100000100100011001100011101011110101011101000010000000001010110001100011111100011010110101010001100011100011100000111011011100010110010100001111101011001010111111101011100111011110001101000111100110101000...

output:

1999 1971 1972 1953 1940 1936 1909 1905 1873 1898 1871 1897 1881 1896 1889 1895 1892 1884 1885 1874 1880 1876 1877 1862 1842 1850 1838 1849 1843 1844 1835 1826 1815 1825 1823 1820 1807 1819 1816 1799 1793 1792 1790 1772 1789 1781 1788 1784 1785 1779 1775 1727 1715 1722 1718 1719 1705 1688 1694 1691 ...

result:

ok 1 cases.

Test #20:

score: 0
Accepted
time: 8ms
memory: 19484kb

input:

2000
0110101010100011101110010101000111001011110000101111001110111111100111000101010001110111000110110001010000010101101001011001111111011111111111011111000011100001111110000101100100000110100100100110110010000101101101100100001101100010011100000011110000100100011110111001101001101100110111011101011...

output:

1997 1988 1993 1991 1944 1978 1950 1977 1952 1976 1955 1975 1965 1974 1970 1968 1962 1961 1959 1953 1947 1948 1940 1908 1921 1918 1905 1898 1904 1901 1899 1892 1891 1880 1890 1885 1883 1875 1872 1845 1857 1854 1849 1850 1837 1829 1828 1825 1817 1815 1813 1810 1806 1800 1781 1774 1771 1770 1760 1769 ...

result:

ok 1 cases.

Test #21:

score: 0
Accepted
time: 12ms
memory: 19564kb

input:

2000
0110000110000000010000010011101111110001110101010000000001101110101010101001111001010100100101001100010100101000110001000101000101010011011000000100011110100001000010000111100110111010110001000100011100100011111001011011111011111001101101111011111011111010011100001111010001011101110000000001011...

output:

1998 2000 1997 1993 1987 1982 1981 1974 1980 1978 1973 1969 1967 1956 1953 1950 1947 1938 1936 1933 1903 1899 1865 1893 1891 1887 1862 1857 1858 1853 1844 1842 1837 1833 1831 1805 1820 1814 1819 1817 1813 1810 1807 1808 1800 1798 1791 1784 1781 1778 1765 1777 1775 1772 1768 1769 1754 1751 1743 1750 ...

result:

ok 1 cases.

Test #22:

score: 0
Accepted
time: 9ms
memory: 19572kb

input:

2000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

1 2000 1999 1998 1997 1996 1995 1994 1993 1992 1991 1990 1989 1988 1987 1986 1985 1984 1983 1982 1981 1980 1979 1978 1977 1976 1975 1974 1973 1972 1971 1970 1969 1968 1967 1966 1965 1964 1963 1962 1961 1960 1959 1958 1957 1956 1955 1954 1953 1952 1951 1950 1949 1948 1947 1946 1945 1944 1943 1942 194...

result:

ok 1 cases.

Test #23:

score: 0
Accepted
time: 12ms
memory: 19480kb

input:

2000
0111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

output:

1 2000 1999 1998 1997 1996 1995 1994 1993 1992 1991 1990 1989 1988 1987 1986 1985 1984 1983 1982 1981 1980 1979 1978 1977 1976 1975 1974 1973 1972 1971 1970 1969 1968 1967 1966 1965 1964 1963 1962 1961 1960 1959 1958 1957 1956 1955 1954 1953 1952 1951 1950 1949 1948 1947 1946 1945 1944 1943 1942 194...

result:

ok 1 cases.