Submission #894919

#TimeUsernameProblemLanguageResultExecution timeMemory
894919LeonaRagingFlip it and Stick it (CCO23_day2problem1)C++14
8 / 25
2 ms1008 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb emplace_back #define pf emplace_front #define fi first #define se second #define T pair<int,int> #define all(val) val.begin(), val.end() #define SZ(val) (int)val.size() #define db(val) "[" #val " = " << (val) << "] " const int maxn = 3e5 + 4; const int N = 16; const int mod = 1e9 + 7; const int INF = 1e9; void coding() { if (fopen("inputf.in", "r")) { freopen("inputf.in", "r", stdin); freopen("outputf.out", "w", stdout); freopen("log.out", "w", stderr); } if (fopen(".INP", "r")) { freopen(".INP", "r", stdin); freopen(".OUT", "w", stdout); } } string s, t; namespace sub1 { void Solve() { bool f = 0; for (int i = 0; i < SZ(s); i++) if (s[i] == '0') return cout << -1, void(); cout << 0; } } namespace sub2 { void Solve() { int res = 0; for (int i = 0; i < SZ(s) - 1; i++) if (s[i] == '0' && s[i + 1] == '1') res++; cout << res; } } namespace sub3 { void Solve() { int cnt0 = 0, cnt1 = 0, res = 0; for (int i = 0; i < SZ(s); i++) { if (s[i] == '0') cnt0++; else cnt1++; if (i < SZ(s) - 1 && s[i] == '0' && s[i + 1] == '0') res++; } if (cnt0 > cnt1 + 1) return cout << -1, void(); cout << res; } } signed main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); coding(); cin >> s >> t; if (t[0] == '1') { for (int i = 0; i < SZ(t); i++) if (t[i] == '0') t[i] = '1'; else t[i] = '0'; for (int i = 0; i < SZ(s); i++) if (s[i] == '0') s[i] = '1'; else s[i] = '0'; } if (t == "0") sub1::Solve(); if (t == "01") sub2::Solve(); if (t == "00") sub3::Solve(); }

Compilation message (stderr)

Main.cpp: In function 'void sub1::Solve()':
Main.cpp:35:14: warning: unused variable 'f' [-Wunused-variable]
   35 |         bool f = 0;
      |              ^
Main.cpp: In function 'void coding()':
Main.cpp:21:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |         freopen("inputf.in", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:22:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |         freopen("outputf.out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:23:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |         freopen("log.out", "w", stderr);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:26:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |         freopen(".INP", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~
Main.cpp:27:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |         freopen(".OUT", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...