# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
238247 | 2020-06-10T11:34:50 Z | Dremix10 | Lamps (JOI19_lamps) | C++17 | 1000 ms | 3540 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef unsigned long long ull; #define F first #define S second #define endl '\n' #define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define maxp 22 #define EPS (ld)(1e-18) #define mod (int)(1e9+7) #define N (int)(1e5+1) int fuse(string s){ int i; int num=0; for(i=0;i<s.size();i++) if(s[i]=='1') num+=(1<<i); return num; } int main (){ fastio; int n; cin>>n; string a,b; cin>>a>>b; int i,j,k; queue <pair<int,int> > q; q.push({fuse(a),0}); int want=fuse(b); map<int,bool> v; while(!q.empty()){ int start=q.front().F; int cost=q.front().S; q.pop(); if(v[start]) continue; v[start]=1; if(start==want){ cout<<cost<<endl; return 0; } cost++; int pos=0; while((start&(1<<pos))==(want&(1<<pos))) pos++; for(j=pos;j<n;j++){ int num=0; for(k=0;k<n;k++) if(pos<=k && k<=j) num+=(1<<k); else if(start&(1<<k)) num+=(1<<k); q.push({num,cost}); } for(j=pos;j<n;j++){ int num=0; for(k=0;k<n;k++) if(pos<=k && k<=j) num+=0; else if(start&(1<<k)) num+=(1<<k); q.push({num,cost}); } for(j=pos;j<n;j++){ int num=0; for(k=0;k<n;k++) if(pos<=k && k<=j){ if(!(start&(1<<k))) num+=(1<<k); } else if(start&(1<<k)) num+=(1<<k); q.push({num,cost}); } } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 4 ms | 384 KB | Output is correct |
3 | Correct | 4 ms | 384 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Correct | 4 ms | 384 KB | Output is correct |
6 | Correct | 4 ms | 384 KB | Output is correct |
7 | Correct | 5 ms | 384 KB | Output is correct |
8 | Correct | 32 ms | 1152 KB | Output is correct |
9 | Correct | 32 ms | 1152 KB | Output is correct |
10 | Correct | 13 ms | 640 KB | Output is correct |
11 | Correct | 13 ms | 640 KB | Output is correct |
12 | Correct | 7 ms | 640 KB | Output is correct |
13 | Correct | 16 ms | 1280 KB | Output is correct |
14 | Correct | 6 ms | 512 KB | Output is correct |
15 | Correct | 8 ms | 640 KB | Output is correct |
16 | Correct | 14 ms | 1152 KB | Output is correct |
17 | Correct | 10 ms | 896 KB | Output is correct |
18 | Correct | 5 ms | 384 KB | Output is correct |
19 | Correct | 5 ms | 384 KB | Output is correct |
20 | Correct | 12 ms | 896 KB | Output is correct |
21 | Correct | 5 ms | 384 KB | Output is correct |
22 | Correct | 6 ms | 512 KB | Output is correct |
23 | Correct | 5 ms | 384 KB | Output is correct |
24 | Correct | 5 ms | 384 KB | Output is correct |
25 | Correct | 5 ms | 384 KB | Output is correct |
26 | Correct | 12 ms | 896 KB | Output is correct |
27 | Correct | 10 ms | 768 KB | Output is correct |
28 | Correct | 6 ms | 512 KB | Output is correct |
29 | Correct | 16 ms | 1152 KB | Output is correct |
30 | Correct | 15 ms | 1280 KB | Output is correct |
31 | Correct | 5 ms | 384 KB | Output is correct |
32 | Correct | 8 ms | 768 KB | Output is correct |
33 | Correct | 10 ms | 896 KB | Output is correct |
34 | Correct | 6 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 4 ms | 384 KB | Output is correct |
3 | Correct | 4 ms | 384 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Correct | 4 ms | 384 KB | Output is correct |
6 | Correct | 4 ms | 384 KB | Output is correct |
7 | Correct | 5 ms | 384 KB | Output is correct |
8 | Correct | 32 ms | 1152 KB | Output is correct |
9 | Correct | 32 ms | 1152 KB | Output is correct |
10 | Correct | 13 ms | 640 KB | Output is correct |
11 | Correct | 13 ms | 640 KB | Output is correct |
12 | Correct | 7 ms | 640 KB | Output is correct |
13 | Correct | 16 ms | 1280 KB | Output is correct |
14 | Correct | 6 ms | 512 KB | Output is correct |
15 | Correct | 8 ms | 640 KB | Output is correct |
16 | Correct | 14 ms | 1152 KB | Output is correct |
17 | Correct | 10 ms | 896 KB | Output is correct |
18 | Correct | 5 ms | 384 KB | Output is correct |
19 | Correct | 5 ms | 384 KB | Output is correct |
20 | Correct | 12 ms | 896 KB | Output is correct |
21 | Correct | 5 ms | 384 KB | Output is correct |
22 | Correct | 6 ms | 512 KB | Output is correct |
23 | Correct | 5 ms | 384 KB | Output is correct |
24 | Correct | 5 ms | 384 KB | Output is correct |
25 | Correct | 5 ms | 384 KB | Output is correct |
26 | Correct | 12 ms | 896 KB | Output is correct |
27 | Correct | 10 ms | 768 KB | Output is correct |
28 | Correct | 6 ms | 512 KB | Output is correct |
29 | Correct | 16 ms | 1152 KB | Output is correct |
30 | Correct | 15 ms | 1280 KB | Output is correct |
31 | Correct | 5 ms | 384 KB | Output is correct |
32 | Correct | 8 ms | 768 KB | Output is correct |
33 | Correct | 10 ms | 896 KB | Output is correct |
34 | Correct | 6 ms | 384 KB | Output is correct |
35 | Execution timed out | 1098 ms | 2936 KB | Time limit exceeded |
36 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 4 ms | 384 KB | Output is correct |
4 | Correct | 4 ms | 384 KB | Output is correct |
5 | Correct | 4 ms | 384 KB | Output is correct |
6 | Correct | 4 ms | 384 KB | Output is correct |
7 | Correct | 12 ms | 3540 KB | Output is correct |
8 | Execution timed out | 1093 ms | 3540 KB | Time limit exceeded |
9 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 4 ms | 384 KB | Output is correct |
3 | Correct | 4 ms | 384 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Correct | 4 ms | 384 KB | Output is correct |
6 | Correct | 4 ms | 384 KB | Output is correct |
7 | Correct | 5 ms | 384 KB | Output is correct |
8 | Correct | 32 ms | 1152 KB | Output is correct |
9 | Correct | 32 ms | 1152 KB | Output is correct |
10 | Correct | 13 ms | 640 KB | Output is correct |
11 | Correct | 13 ms | 640 KB | Output is correct |
12 | Correct | 7 ms | 640 KB | Output is correct |
13 | Correct | 16 ms | 1280 KB | Output is correct |
14 | Correct | 6 ms | 512 KB | Output is correct |
15 | Correct | 8 ms | 640 KB | Output is correct |
16 | Correct | 14 ms | 1152 KB | Output is correct |
17 | Correct | 10 ms | 896 KB | Output is correct |
18 | Correct | 5 ms | 384 KB | Output is correct |
19 | Correct | 5 ms | 384 KB | Output is correct |
20 | Correct | 12 ms | 896 KB | Output is correct |
21 | Correct | 5 ms | 384 KB | Output is correct |
22 | Correct | 6 ms | 512 KB | Output is correct |
23 | Correct | 5 ms | 384 KB | Output is correct |
24 | Correct | 5 ms | 384 KB | Output is correct |
25 | Correct | 5 ms | 384 KB | Output is correct |
26 | Correct | 12 ms | 896 KB | Output is correct |
27 | Correct | 10 ms | 768 KB | Output is correct |
28 | Correct | 6 ms | 512 KB | Output is correct |
29 | Correct | 16 ms | 1152 KB | Output is correct |
30 | Correct | 15 ms | 1280 KB | Output is correct |
31 | Correct | 5 ms | 384 KB | Output is correct |
32 | Correct | 8 ms | 768 KB | Output is correct |
33 | Correct | 10 ms | 896 KB | Output is correct |
34 | Correct | 6 ms | 384 KB | Output is correct |
35 | Execution timed out | 1098 ms | 2936 KB | Time limit exceeded |
36 | Halted | 0 ms | 0 KB | - |