Submission #1144876

#TimeUsernameProblemLanguageResultExecution timeMemory
1144876SmuggingSpunGrowing Vegetable is Fun 3 (JOI19_ho_t3)C++20
5 / 100
65 ms7864 KiB
#include<bits/stdc++.h> #define taskname "C" using namespace std; int n; string s; namespace sub1{ void solve(){ unordered_map<string, int>f; f[s] = 1; queue<string>q; q.push(s); while(!q.empty()){ s = q.front(); q.pop(); bool flag = true; for(int i = 1; i < n; i++){ if(s[i] == s[i - 1]){ flag = false; break; } } if(flag){ return void(cout << f[s] - 1); } int N = f[s]; for(int i = 1; i < n; i++){ swap(s[i], s[i - 1]); if(f[s] == 0){ f[s] = N + 1; q.push(s); } swap(s[i], s[i - 1]); } } cout << -1; } } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if(fopen(taskname".inp", "r")){ freopen(taskname".inp", "r", stdin); } cin >> n >> s; if(n <= 15){ sub1::solve(); } }

Compilation message (stderr)

joi2019_ho_t3.cpp: In function 'int main()':
joi2019_ho_t3.cpp:41:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |                 freopen(taskname".inp", "r", stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...