제출 #1059580

#제출 시각아이디문제언어결과실행 시간메모리
1059580KasymKMiners (IOI07_miners)C++17
45 / 100
1576 ms808 KiB
#include "bits/stdc++.h" using namespace std; #define ff first #define ss second #define all(v) v.begin(), v.end() #define ll long long #define pb push_back #define pii pair<int, int> #define wr puts("----------------") template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;} template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;} int get(string v){ int n = (int)v.size(); int sm = 0; for(int i = 0; i < n; ++i){ int ok = 0, ok1 = 0, ok2 = 0; for(int j = i-2; j <= i; ++j){ if(j < 0) continue; if(v[j] == 'M') ok = 1; else if(v[j] == 'B') ok1 = 1; else ok2 = 1; } sm += ok+ok1+ok2; } return sm; } int main(){ int n; scanf("%d", &n); string s; cin >> s; int answer = 0; for(int mk = 0; mk < (1<<n); ++mk){ string t = "", t1 = ""; for(int i = 0; i < n; ++i){ if(mk>>i&1) t += s[i]; else t1 += s[i]; } int coal = get(t)+get(t1); umax(answer, coal); } printf("%d\n", answer); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

miners.cpp: In function 'int main()':
miners.cpp:35:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
#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...
#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...