# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
238110 |
2020-06-09T23:18:58 Z |
Dremix10 |
Lamps (JOI19_lamps) |
C++17 |
|
1000 ms |
115640 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++;
for(i=0;i<n;i++)
for(j=i;j<n;j++){
int num=0;
for(k=0;k<n;k++)
if(i<=k && k<=j)
num+=(1<<k);
else if(start&(1<<k))
num+=(1<<k);
q.push({num,cost});
}
for(i=0;i<n;i++)
for(j=i;j<n;j++){
int num=0;
for(k=0;k<n;k++)
if(i<=k && k<=j)
num+=0;
else if(start&(1<<k))
num+=(1<<k);
q.push({num,cost});
}
for(i=0;i<n;i++)
for(j=i;j<n;j++){
int num=0;
for(k=0;k<n;k++)
if(i<=k && k<=j){
if(!(start&(1<<k)))
num+=(1<<k);
}
else if(start&(1<<k))
num+=(1<<k);
q.push({num,cost});
}
}
}
Compilation message
lamp.cpp: In function 'int fuse(std::__cxx11::string)':
lamp.cpp:18:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(i=0;i<s.size();i++)
~^~~~~~~~~
# |
Verdict |
Execution time |
Memory |
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 |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Execution timed out |
1081 ms |
115640 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
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 |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Execution timed out |
1081 ms |
115640 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
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 |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
4 ms |
384 KB |
Output is correct |
7 |
Correct |
12 ms |
5416 KB |
Output is correct |
8 |
Execution timed out |
1085 ms |
5332 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
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 |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Execution timed out |
1081 ms |
115640 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |