QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#108786#6391. Airplanecyan17#10 685ms39432kbC++172.5kb2023-05-26 17:28:542024-05-31 13:43:05

Judging History

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

  • [2024-05-31 13:43:05]
  • 评测
  • 测评结果:10
  • 用时:685ms
  • 内存:39432kb
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-26 17:28:54]
  • 提交

answer

#include "bits/stdc++.h"
using namespace std;

#define int long long
#define fr first
#define sc second
#define eb emplace_back
const char nl = '\n';

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");} 
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cerr << "LINE(" << __LINE__ << ") -> " <<"[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif

void solve() {

}

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n, m; cin >> n >> m;
    int a[n + 1]; for(int i = 1; i <= n; ++i) cin >> a[i];
    vector<int> adj[n + 1];
    for(int i = 0; i < m; ++i) {
        int u, v; cin >> u >> v;
        adj[u].eb(v); adj[v].eb(u);
    }
    for(int i = 1; i <= n; ++i) {
        adj[i].eb(i);
    }

    int dist[n + 1][2001];
    for(int i = 0; i <= n; ++i) for(int j = 0; j < 2001; ++j) dist[i][j] = -1;
    bool proc[n + 1][2001] = {};
    priority_queue<pair<int, pair<int, int>>> pq;

    dist[1][0] = 0;
    pq.push({-dist[1][0], {1, 0}});
    while(!pq.empty()) {
        int c = pq.top().sc.fr, h = pq.top().sc.sc;
        pq.pop();
        if(proc[c][h]) continue;
        proc[c][h] = 1;

        for(int d : adj[c]) {
            for(int dh : {-1, 0, 1}) {
                if(h + dh < 0 || h + dh > 2000) continue;
                if(proc[d][h + dh]) continue;
                if(a[d] > h + dh) continue;
                if(dist[d][h + dh] == -1 || dist[d][h + dh] > dist[c][h] + 1) {
                    dist[d][h + dh] = dist[c][h] + 1;
                    pq.push({-dist[d][h + dh], {d, h + dh}});
                }
            }
        }
    }

    cout << dist[n][0] << nl;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Memory Limit Exceeded

Test #1:

score: 0
Memory Limit Exceeded

input:

200000 199999
0 199 58 60 83 5 10 182 87 65 104 153 197 137 80 143 34 181 62 48 10 57 86 58 117 10 171 188 95 52 95 140 126 0 196 85 87 14 10 139 177 92 31 18 102 146 68 9 91 124 156 38 41 121 183 10 32 174 171 29 49 26 118 1 69 185 57 168 54 159 195 95 9 32 195 70 85 174 158 82 33 197 66 189 198 11...

output:


result:


Subtask #2:

score: 10
Accepted

Test #8:

score: 10
Accepted
time: 0ms
memory: 3764kb

input:

6 10
0 0 6 1 8 0
5 6
2 3
5 4
6 4
3 5
6 2
3 6
3 4
3 1
6 1

output:

1

result:

ok single line: '1'

Test #9:

score: 10
Accepted
time: 1ms
memory: 3964kb

input:

4 5
0 1 2 0
2 4
1 2
3 2
4 1
4 3

output:

1

result:

ok single line: '1'

Test #10:

score: 10
Accepted
time: 3ms
memory: 4052kb

input:

20 40
0 2 1 5 3 4 1 5 3 2 5 5 5 3 3 4 4 3 4 0
4 3
15 18
11 18
10 13
1 3
9 14
16 14
16 1
5 3
13 15
20 7
20 16
9 11
16 11
1 2
6 2
19 10
7 13
15 10
7 15
8 11
5 9
8 12
6 7
7 14
2 18
17 16
8 3
1 10
5 2
4 2
11 13
17 3
11 5
4 8
13 6
17 1
10 7
5 6
13 9

output:

4

result:

ok single line: '4'

Test #11:

score: 10
Accepted
time: 148ms
memory: 39288kb

input:

2000 2000
0 1990 1247 1110 1102 1411 1445 1492 1349 1302 1404 1541 1660 1333 1461 1710 1655 1489 1310 1660 1141 1069 1167 1020 1564 1746 1354 1607 1144 1636 1901 1099 1167 1112 1001 1210 1126 1537 1082 1814 1469 1884 1375 1703 1393 1335 1194 1444 1895 1933 1038 1357 1405 1039 1804 1958 1642 1418 169...

output:

4027

result:

ok single line: '4027'

Test #12:

score: 10
Accepted
time: 464ms
memory: 39364kb

input:

2000 2000
0 53 12 10 76 82 78 52 30 63 13 87 53 19 51 80 25 82 8 75 12 19 5 49 9 28 5 51 65 9 50 57 9 95 39 33 12 94 26 83 76 82 15 99 39 27 95 13 48 23 58 86 96 100 19 84 93 13 69 61 20 25 23 74 19 12 5 108 16 67 50 16 51 106 79 107 42 39 105 79 17 22 30 28 84 25 80 36 87 22 82 107 31 77 103 96 70 ...

output:

272

result:

ok single line: '272'

Test #13:

score: 10
Accepted
time: 142ms
memory: 39016kb

input:

2000 2001
0 1532 1936 1350 1411 1324 1289 1350 1176 1065 1668 1081 1175 1337 1755 1595 1530 1401 1553 1118 1045 1136 1120 1776 1670 1225 1267 1005 1170 1148 1363 1397 1448 1985 1510 1167 1131 1105 1993 1437 1138 1922 1106 1714 1205 1934 1565 1896 1021 1458 1339 1331 1054 1105 1650 1144 1456 1779 117...

output:

3914

result:

ok single line: '3914'

Test #14:

score: 10
Accepted
time: 497ms
memory: 39132kb

input:

2000 2010
0 2 3 2 4 4 6 6 7 3 4 5 5 6 7 6 7 5 3 4 5 2 5 6 7 3 6 8 7 7 5 6 6 4 8 10 6 7 4 3 10 6 8 6 7 6 7 11 9 8 7 8 6 7 12 11 7 8 9 13 9 9 10 13 11 12 6 8 14 9 10 7 11 11 9 14 11 13 15 8 11 12 12 15 11 12 8 15 16 11 12 12 9 11 9 12 13 16 14 9 14 13 16 13 13 9 17 11 18 12 17 14 18 11 15 15 17 12 15 ...

output:

35

result:

ok single line: '35'

Test #15:

score: 10
Accepted
time: 140ms
memory: 39128kb

input:

2000 2015
0 1980 1365 1349 1698 1949 1823 1611 1926 1298 1981 1818 2000 1789 1832 1371 1021 1765 1467 1273 1259 1941 1578 1597 1459 1817 1293 1362 1997 1465 1351 1145 1982 1838 1099 1899 1950 1771 1819 1999 1173 1013 1033 1459 1001 1994 1653 1224 1751 1534 1775 1221 1956 1291 1176 1864 1948 1322 105...

output:

3882

result:

ok single line: '3882'

Test #16:

score: 10
Accepted
time: 496ms
memory: 39012kb

input:

2000 2020
0 1 2 6 5 6 4 4 5 2 1 5 2 7 4 4 8 6 6 2 6 6 5 7 6 9 6 5 9 7 9 4 6 5 11 8 6 5 8 11 6 11 10 13 9 7 11 14 11 15 5 13 14 11 8 5 11 7 7 16 5 9 11 14 13 9 17 12 11 8 9 10 7 8 11 8 11 7 8 11 12 14 11 14 15 17 8 10 8 12 9 10 11 9 19 10 18 9 11 11 11 11 11 9 20 11 11 9 14 22 11 11 19 12 12 12 10 13...

output:

25

result:

ok single line: '25'

Test #17:

score: 10
Accepted
time: 138ms
memory: 39012kb

input:

2000 2050
0 1162 1770 1285 1260 1570 1982 1444 2000 1412 1924 1692 1196 1269 1324 1251 1673 1535 1739 1237 1009 1150 1679 1266 1183 1017 1737 1774 1046 1702 1724 1137 1297 1644 1684 1925 1222 1622 1025 1155 1002 1833 1520 1985 1869 1466 1752 1227 1956 1680 1820 1194 1519 1712 1595 1935 1344 1547 170...

output:

3816

result:

ok single line: '3816'

Test #18:

score: 10
Accepted
time: 534ms
memory: 39108kb

input:

2000 2200
0 1 9 2 9 6 8 8 3 6 7 3 7 10 4 7 4 11 11 15 6 6 9 12 3 11 13 12 7 4 11 10 12 6 7 9 12 15 16 6 9 15 10 9 8 11 11 6 8 15 6 13 15 5 10 15 6 10 7 6 10 8 12 11 12 8 12 9 8 13 14 7 11 12 16 10 7 9 15 15 9 12 7 14 17 13 13 19 17 10 10 11 11 18 14 19 10 12 8 16 11 19 10 19 18 15 15 20 9 15 14 16 1...

output:

24

result:

ok single line: '24'

Test #19:

score: 10
Accepted
time: 173ms
memory: 39368kb

input:

2000 3000
0 1249 1256 1118 1126 1622 1152 1586 1628 1879 1332 1571 1224 1789 1181 1131 1167 1202 1528 1769 1733 1448 1845 1389 1059 2000 1112 1846 1664 1315 1629 1870 1098 1957 1613 1680 1658 1809 1061 1490 1198 1929 1325 1007 1139 1318 1047 1964 1320 1191 1416 1742 1489 1925 1029 1228 1558 1315 152...

output:

2808

result:

ok single line: '2808'

Test #20:

score: 10
Accepted
time: 96ms
memory: 39432kb

input:

2000 4000
0 1980 1517 1527 1676 2000 1760 1795 1799 1525 1957 1920 1623 1959 1819 1895 1997 1746 1806 1605 1599 1588 1607 1792 1675 1916 1515 1941 1848 1717 1900 1540 1655 1504 1729 1693 1604 1887 1949 1638 1646 1968 1643 1916 1512 1966 1532 1966 1564 1724 1507 1540 1713 1816 1908 1676 1777 1559 165...

output:

3348

result:

ok single line: '3348'

Test #21:

score: 10
Accepted
time: 685ms
memory: 39172kb

input:

2000 4000
0 11 7 14 11 5 7 2 2 4 7 4 12 17 16 14 4 12 13 4 7 6 11 7 5 7 17 18 6 8 19 13 16 5 12 12 15 18 12 16 6 7 8 19 11 11 6 18 9 9 15 10 7 14 19 17 11 5 4 14 9 16 15 17 9 10 9 8 11 18 17 5 13 20 15 19 4 6 6 10 13 7 20 15 16 9 6 19 19 20 16 16 9 16 8 16 9 11 12 8 20 11 6 21 8 16 15 19 12 8 9 14 6...

output:

19

result:

ok single line: '19'

Test #22:

score: 10
Accepted
time: 663ms
memory: 39148kb

input:

2000 4000
0 65 44 21 21 34 74 39 78 23 58 40 60 71 38 3 97 86 102 35 77 48 19 9 87 41 27 83 32 91 72 51 60 50 82 82 73 101 30 81 80 52 13 56 42 29 30 87 43 101 99 58 12 62 26 38 30 28 36 86 28 73 105 51 39 92 26 21 68 9 16 77 81 98 32 81 19 72 99 9 30 36 40 59 93 12 19 68 43 42 90 104 57 78 16 56 57...

output:

100

result:

ok single line: '100'

Subtask #3:

score: 0
Wrong Answer

Dependency #2:

100%
Accepted

Test #23:

score: 0
Wrong Answer
time: 11ms
memory: 39004kb

input:

2000 2037
0 54690170 93351623 83472845 35611192 16997239 91266586 67753803 96779399 19868930 44883547 8667270 14743835 88895341 7795730 67505347 42672061 93860108 88628584 91944328 76624408 62327480 92377003 57852449 71536702 46048591 95278030 85805340 51440161 42807089 2455270 97621197 60345371 483...

output:

-1

result:

wrong answer 1st lines differ - expected: '183216836', found: '-1'

Subtask #4:

score: 0
Skipped

Dependency #1:

0%