Submission #705511

#TimeUsernameProblemLanguageResultExecution timeMemory
705511BidoTeimaOrchard (NOI14_orchard)C++17
25 / 25
129 ms17896 KiB
/* ID: BidoTeima LANG: C++11 TASK: */ #include <bits/stdc++.h> using namespace std; using ll = long long; void moo(string filename); void ACPLS(string str = "") { if(str=="NOF")return; if(str.size() && str != "IIOT") moo(str); else if(str != "IIOT"){ #ifndef ONLINE_JUDGE freopen("output.txt", "w", stdout); freopen("input.txt", "r", stdin); #endif } ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); } void moo(string fileName){ freopen((fileName+".in").c_str(),"r",stdin); freopen((fileName+".out").c_str(),"w",stdout); } #define tc \ int tttttt/*,subtask*/; \ cin >> tttttt/* >> subtask*/; \ while (tttttt--)/*end */ int main() { ACPLS("IIOT"); int n,m; cin>>n>>m; int a[n+1][m+1]={0}; int total = 0; for(int i = 1; i <= n; i++){ for(int j = 1; j <= m; j++){ char ch; cin>>ch; a[i][j]=ch-'0'; total += a[i][j]; } } int colsum[n + 1][m + 1]={0}; for(int j = 1; j <= m; j++){ for(int i = 1; i <= n; i++){ colsum[i][j] = colsum[i - 1][j] + a[i][j]; } } int ans = 1e9; for(int a = 1; a <= n; a++){ for(int x = a; x <= n; x++){ int mn = 0; int cursum = 0; for(int i = 1; i <= m; i++){ cursum += colsum[x][i] - colsum[a - 1][i]; ans = min(ans, total + i * (x - a + 1) - 2 * cursum + mn); mn = min(mn, 2 * cursum - i * (x - a + 1)); } } } cout << ans << '\n'; }

Compilation message (stderr)

orchard.cpp: In function 'void ACPLS(std::string)':
orchard.cpp:17:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |         freopen("output.txt", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
orchard.cpp:18:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |         freopen("input.txt", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
orchard.cpp: In function 'void moo(std::string)':
orchard.cpp:26:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |     freopen((fileName+".in").c_str(),"r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
orchard.cpp:27:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |     freopen((fileName+".out").c_str(),"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...