# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
129169 | 2019-07-11T18:43:19 Z | mahmoudbadawy | Lamps (JOI19_lamps) | C++17 | 1000 ms | 4928 KB |
#include <bits/stdc++.h> using namespace std; string a,b; int n; int dis[(1<<18)]; int conv(string s) { int res=0; for(int i=0;i<s.size();i++) res=res*2+(s[i]-'0'); return res; } int main() { cin >> n >> a >> b; queue<int> q; q.push(conv(a)); int bb=conv(b); memset(dis,-1,sizeof dis); dis[conv(a)]=0; while(q.size()) { int s=q.front(); q.pop(); if(s==bb) break; for(int i=0;i<n;i++) { int sd=s; for(int j=i;j<n;j++) { sd&=(~(1<<j)); if(dis[sd]!=-1) continue; dis[sd]=dis[s]+1; q.push(sd); } } for(int i=0;i<n;i++) { int sd=s; for(int j=i;j<n;j++) { sd|=(1<<j); if(dis[sd]!=-1) continue; dis[sd]=dis[s]+1; q.push(sd); } } for(int i=0;i<n;i++) { int sd=s; for(int j=i;j<n;j++) { sd^=(1<<j); if(dis[sd]!=-1) continue; dis[sd]=dis[s]+1; q.push(sd); } } } cout << dis[bb] << endl; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 1272 KB | Output is correct |
2 | Correct | 3 ms | 1272 KB | Output is correct |
3 | Correct | 3 ms | 1400 KB | Output is correct |
4 | Correct | 3 ms | 1400 KB | Output is correct |
5 | Correct | 3 ms | 1272 KB | Output is correct |
6 | Correct | 3 ms | 1400 KB | Output is correct |
7 | Correct | 3 ms | 1400 KB | Output is correct |
8 | Correct | 391 ms | 1840 KB | Output is correct |
9 | Correct | 387 ms | 1884 KB | Output is correct |
10 | Correct | 171 ms | 1664 KB | Output is correct |
11 | Correct | 168 ms | 1528 KB | Output is correct |
12 | Correct | 33 ms | 1784 KB | Output is correct |
13 | Correct | 91 ms | 1656 KB | Output is correct |
14 | Correct | 70 ms | 1812 KB | Output is correct |
15 | Correct | 107 ms | 1676 KB | Output is correct |
16 | Correct | 259 ms | 1788 KB | Output is correct |
17 | Correct | 99 ms | 1660 KB | Output is correct |
18 | Correct | 37 ms | 1656 KB | Output is correct |
19 | Correct | 25 ms | 1528 KB | Output is correct |
20 | Correct | 235 ms | 1912 KB | Output is correct |
21 | Correct | 9 ms | 1528 KB | Output is correct |
22 | Correct | 33 ms | 1784 KB | Output is correct |
23 | Correct | 62 ms | 1656 KB | Output is correct |
24 | Correct | 4 ms | 1400 KB | Output is correct |
25 | Correct | 5 ms | 1528 KB | Output is correct |
26 | Correct | 216 ms | 2048 KB | Output is correct |
27 | Correct | 78 ms | 1528 KB | Output is correct |
28 | Correct | 36 ms | 1532 KB | Output is correct |
29 | Correct | 333 ms | 1912 KB | Output is correct |
30 | Correct | 118 ms | 1656 KB | Output is correct |
31 | Correct | 5 ms | 1400 KB | Output is correct |
32 | Correct | 42 ms | 1784 KB | Output is correct |
33 | Correct | 103 ms | 1528 KB | Output is correct |
34 | Correct | 27 ms | 1528 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 1272 KB | Output is correct |
2 | Correct | 3 ms | 1272 KB | Output is correct |
3 | Correct | 3 ms | 1400 KB | Output is correct |
4 | Correct | 3 ms | 1400 KB | Output is correct |
5 | Correct | 3 ms | 1272 KB | Output is correct |
6 | Correct | 3 ms | 1400 KB | Output is correct |
7 | Correct | 3 ms | 1400 KB | Output is correct |
8 | Correct | 391 ms | 1840 KB | Output is correct |
9 | Correct | 387 ms | 1884 KB | Output is correct |
10 | Correct | 171 ms | 1664 KB | Output is correct |
11 | Correct | 168 ms | 1528 KB | Output is correct |
12 | Correct | 33 ms | 1784 KB | Output is correct |
13 | Correct | 91 ms | 1656 KB | Output is correct |
14 | Correct | 70 ms | 1812 KB | Output is correct |
15 | Correct | 107 ms | 1676 KB | Output is correct |
16 | Correct | 259 ms | 1788 KB | Output is correct |
17 | Correct | 99 ms | 1660 KB | Output is correct |
18 | Correct | 37 ms | 1656 KB | Output is correct |
19 | Correct | 25 ms | 1528 KB | Output is correct |
20 | Correct | 235 ms | 1912 KB | Output is correct |
21 | Correct | 9 ms | 1528 KB | Output is correct |
22 | Correct | 33 ms | 1784 KB | Output is correct |
23 | Correct | 62 ms | 1656 KB | Output is correct |
24 | Correct | 4 ms | 1400 KB | Output is correct |
25 | Correct | 5 ms | 1528 KB | Output is correct |
26 | Correct | 216 ms | 2048 KB | Output is correct |
27 | Correct | 78 ms | 1528 KB | Output is correct |
28 | Correct | 36 ms | 1532 KB | Output is correct |
29 | Correct | 333 ms | 1912 KB | Output is correct |
30 | Correct | 118 ms | 1656 KB | Output is correct |
31 | Correct | 5 ms | 1400 KB | Output is correct |
32 | Correct | 42 ms | 1784 KB | Output is correct |
33 | Correct | 103 ms | 1528 KB | Output is correct |
34 | Correct | 27 ms | 1528 KB | Output is correct |
35 | Runtime error | 5 ms | 2552 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
36 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 1400 KB | Output is correct |
2 | Correct | 3 ms | 1272 KB | Output is correct |
3 | Correct | 3 ms | 1372 KB | Output is correct |
4 | Correct | 3 ms | 1400 KB | Output is correct |
5 | Correct | 3 ms | 1400 KB | Output is correct |
6 | Correct | 3 ms | 1400 KB | Output is correct |
7 | Correct | 126 ms | 4928 KB | Output is correct |
8 | Execution timed out | 1075 ms | 4876 KB | Time limit exceeded |
9 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 1272 KB | Output is correct |
2 | Correct | 3 ms | 1272 KB | Output is correct |
3 | Correct | 3 ms | 1400 KB | Output is correct |
4 | Correct | 3 ms | 1400 KB | Output is correct |
5 | Correct | 3 ms | 1272 KB | Output is correct |
6 | Correct | 3 ms | 1400 KB | Output is correct |
7 | Correct | 3 ms | 1400 KB | Output is correct |
8 | Correct | 391 ms | 1840 KB | Output is correct |
9 | Correct | 387 ms | 1884 KB | Output is correct |
10 | Correct | 171 ms | 1664 KB | Output is correct |
11 | Correct | 168 ms | 1528 KB | Output is correct |
12 | Correct | 33 ms | 1784 KB | Output is correct |
13 | Correct | 91 ms | 1656 KB | Output is correct |
14 | Correct | 70 ms | 1812 KB | Output is correct |
15 | Correct | 107 ms | 1676 KB | Output is correct |
16 | Correct | 259 ms | 1788 KB | Output is correct |
17 | Correct | 99 ms | 1660 KB | Output is correct |
18 | Correct | 37 ms | 1656 KB | Output is correct |
19 | Correct | 25 ms | 1528 KB | Output is correct |
20 | Correct | 235 ms | 1912 KB | Output is correct |
21 | Correct | 9 ms | 1528 KB | Output is correct |
22 | Correct | 33 ms | 1784 KB | Output is correct |
23 | Correct | 62 ms | 1656 KB | Output is correct |
24 | Correct | 4 ms | 1400 KB | Output is correct |
25 | Correct | 5 ms | 1528 KB | Output is correct |
26 | Correct | 216 ms | 2048 KB | Output is correct |
27 | Correct | 78 ms | 1528 KB | Output is correct |
28 | Correct | 36 ms | 1532 KB | Output is correct |
29 | Correct | 333 ms | 1912 KB | Output is correct |
30 | Correct | 118 ms | 1656 KB | Output is correct |
31 | Correct | 5 ms | 1400 KB | Output is correct |
32 | Correct | 42 ms | 1784 KB | Output is correct |
33 | Correct | 103 ms | 1528 KB | Output is correct |
34 | Correct | 27 ms | 1528 KB | Output is correct |
35 | Runtime error | 5 ms | 2552 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
36 | Halted | 0 ms | 0 KB | - |