Submission #235402

#TimeUsernameProblemLanguageResultExecution timeMemory
235402Charis02Lamps (JOI19_lamps)C++14
Compilation error
0 ms0 KiB
#include<iostream> #include<stdio.h> #include<vector> #include<cmath> #include<queue> #include<string.h> #include<map> #include<set> #include<algorithm> #define ll long long #define pi pair < ll,ll > #define mp(a,b) make_pair(a,b) #define mid (low+high)/2 #define rep(i,a,b) for(int i = a;i < b;i++) #define N 300004 #define INF 1e9+7 using namespace std; ll n; string s,t; unordered_map < string,bool > vis; unordered_map < string,ll > steps; void solve() { queue < string > q; q.push(s); vis[s]=true; steps[s] = 0; while(!q.empty()) { string cur = q.front(); q.pop(); string tmp = cur; rep(i,0,n) { tmp = cur; rep(j,i,n) { tmp[j] = '1'; if(!vis[tmp]) { vis[tmp]=true; steps[tmp]=steps[cur]+1; q.push(tmp); } } } rep(i,0,n) { tmp = cur; rep(j,i,n) { tmp[j] = '0'; if(!vis[tmp]) { vis[tmp]=true; steps[tmp]=steps[cur]+1; q.push(tmp); } } } rep(i,0,n) { tmp = cur; rep(j,i,n) { tmp[j] = ((tmp[j]-'0')+1)%2 + '0'; if(!vis[tmp]) { vis[tmp]=true; steps[tmp]=steps[cur]+1; q.push(tmp); } } } } return; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> n; cin >> s; cin >> t; solve(); cout << steps[t]; return 0; }

Compilation message (stderr)

lamp.cpp:22:1: error: 'unordered_map' does not name a type
 unordered_map < string,bool > vis;
 ^~~~~~~~~~~~~
lamp.cpp:23:1: error: 'unordered_map' does not name a type
 unordered_map < string,ll > steps;
 ^~~~~~~~~~~~~
lamp.cpp: In function 'void solve()':
lamp.cpp:29:5: error: 'vis' was not declared in this scope
     vis[s]=true;
     ^~~
lamp.cpp:30:5: error: 'steps' was not declared in this scope
     steps[s] = 0;
     ^~~~~
lamp.cpp:30:5: note: suggested alternative: 'stpcpy'
     steps[s] = 0;
     ^~~~~
     stpcpy
lamp.cpp: In function 'int main()':
lamp.cpp:95:13: error: 'steps' was not declared in this scope
     cout << steps[t];
             ^~~~~
lamp.cpp:95:13: note: suggested alternative: 'stpcpy'
     cout << steps[t];
             ^~~~~
             stpcpy