Submission #1060409

#TimeUsernameProblemLanguageResultExecution timeMemory
1060409KazooCollecting Mushrooms (NOI18_collectmushrooms)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long const int maxR = 5e5+5; int r, c, d, k; string garden[maxR]; bool watered[maxR][maxR]; int main(){ cin >> r >> c >> d >> k; for(int i = 0; i<r; i++){ cin >> garden[i]; } vector<vector<int>> kena; for(int i = 0; i<r; i++){ vector<int> ps; for(int j = 0; j<c; j++){ ps.push_back(0); } kena.push_back(ps); } int cnt = 0; for(int i = 0; i<r; i++){ for(int j = 0; j<c; j++){ if(garden[i][j]=='S') { // atas kiri [i-d][j-d] // bawah kanan [i+d][j+d] // atas kanan [i-d][j+d] // bawah kiri [i+d][j-d] int atas = max(i-d, 0); int kiri = max(j-d, 0); kena[atas][kiri]++; int kanan = -1, bawah = -1; if(i+d+1<=r-1) bawah = i+d+1; if(j+d+1<=c-1) kanan = j+d+1; if(kanan!=-1) kena[atas][kanan]--; if(bawah!=-1) kena[bawah][kiri]--; if(kanan!=-1 && bawah!=-1) kena[kanan][bawah]++; } } } ll ans = 0; for(int i = 0; i<r; i++){ for(int j = 0; j<c; j++){ if(i!=0) kena[i][j] += kena[i-1][j]; if(j!=0) kena[i][j] += kena[i][j-1]; if(i!=0 && j!=0) kena[i][j] -= kena[i-1][j-1]; if(garden[i][j]=='M' && kena[i][j] >= k) ans++; } // cout << endl; } cout << ans << endl; }

Compilation message (stderr)

mushrooms.cpp: In function 'int main()':
mushrooms.cpp:24:9: warning: unused variable 'cnt' [-Wunused-variable]
   24 |     int cnt = 0;
      |         ^~~
/tmp/ccFTjZ9v.o: in function `__tcf_0':
mushrooms.cpp:(.text+0x9): relocation truncated to fit: R_X86_64_PC32 against symbol `garden[abi:cxx11]' defined in .bss section in /tmp/ccFTjZ9v.o
/tmp/ccFTjZ9v.o: in function `main':
mushrooms.cpp:(.text.startup+0x9): relocation truncated to fit: R_X86_64_PC32 against symbol `r' defined in .bss section in /tmp/ccFTjZ9v.o
mushrooms.cpp:(.text.startup+0x10): relocation truncated to fit: R_X86_64_PC32 against symbol `std::cin' defined in .bss._ZSt3cin section in /usr/lib/gcc/x86_64-linux-gnu/10/libstdc++.a(globals_io.o)
mushrooms.cpp:(.text.startup+0x38): relocation truncated to fit: R_X86_64_PC32 against symbol `c' defined in .bss section in /tmp/ccFTjZ9v.o
mushrooms.cpp:(.text.startup+0x47): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccFTjZ9v.o
mushrooms.cpp:(.text.startup+0x56): relocation truncated to fit: R_X86_64_PC32 against symbol `k' defined in .bss section in /tmp/ccFTjZ9v.o
mushrooms.cpp:(.text.startup+0x64): relocation truncated to fit: R_X86_64_PC32 against symbol `r' defined in .bss section in /tmp/ccFTjZ9v.o
mushrooms.cpp:(.text.startup+0x73): relocation truncated to fit: R_X86_64_PC32 against symbol `garden[abi:cxx11]' defined in .bss section in /tmp/ccFTjZ9v.o
mushrooms.cpp:(.text.startup+0x7c): relocation truncated to fit: R_X86_64_PC32 against symbol `std::cin' defined in .bss._ZSt3cin section in /usr/lib/gcc/x86_64-linux-gnu/10/libstdc++.a(globals_io.o)
mushrooms.cpp:(.text.startup+0x94): relocation truncated to fit: R_X86_64_PC32 against symbol `r' defined in .bss section in /tmp/ccFTjZ9v.o
mushrooms.cpp:(.text.startup+0xeb): additional relocation overflows omitted from the output
/usr/bin/ld: failed to convert GOTPCREL relocation; relink with --no-relax
collect2: error: ld returned 1 exit status