제출 #762785

#제출 시각아이디문제언어결과실행 시간메모리
762785AmirElarbi바이러스 (JOI19_virus)C++14
14 / 100
40 ms3312 KiB
#include <bits/stdc++.h> #define ve vector #define vi vector<int> #define vii vector<ii> #define ii pair<int,int> #define fi first #define se second #define ll long long #define INF 1e9+7 #define pb push_back #define optimise ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) using namespace std; #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; const int MOD = 1e9+7; const int nax = 800+5; void readio(){ #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif } int grid[nax][nax]; int mx[4]; int ad[4][2] = {{-1,0}, {1,0}, {0,1}, {0,-1}}; map<char,int> mp; int m,r,c; /*int dfs(int x, int y){ vis[x][y] = 1; int cur = 1; for(int k = 2; k < 4; k++){ int nx = x + ad[k][0], ny = y + ad[k][1]; if(nx < 0 || ny < 0 || nx >= r || ny >= c || vis[nx][ny] || grid[nx][ny] > mx[k] || !grid[nx][ny]) continue; cur += dfs(nx, ny); } return cur; }*/ int main() { optimise; cin >> m >> r >> c; string wind; cin >> wind; wind = wind + wind; mp['S'] = 0, mp['N'] = 1, mp['W'] = 2, mp['E'] = 3; int cur = 0; for (int i = 0; i < wind.size(); ++i) { if(i && wind[i] != wind[i-1]) cur = 0; cur++; mx[mp[wind[i]]] = max(cur, mx[mp[wind[i]]]); } if(mx[2] == wind.size()) mx[2] = INF; if(mx[3] == wind.size()) mx[3] = INF; for (int i = 0; i < r; ++i) { for (int j = 0; j < c; ++j) { cin >> grid[i][j]; } } int mn = INF, aff = 0; for (int i = 0; i < r; ++i) { int low = 0, high = 1; for (int j = 0; j < c; ++j) { low = min(low, j); high = max(high, j+1); if(!grid[i][j]) { low = j+1; continue; } if(grid[i][j-1] > mx[3]) low = j; while(high < c && grid[i][high] <= mx[2] && grid[i][high] != 0) high++; int cur = high - low; //cout << j << " " << low << " " << high << endl; if(mn > cur) mn = cur, aff = 1; else if(mn == cur) aff++; } } cout << mn << " " << aff << endl; }

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

virus.cpp: In function 'int main()':
virus.cpp:50:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |     for (int i = 0; i < wind.size(); ++i)
      |                     ~~^~~~~~~~~~~~~
virus.cpp:56:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |     if(mx[2] == wind.size()) mx[2] = INF;
      |        ~~~~~~^~~~~~~~~~~~~~
virus.cpp:57:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |     if(mx[3] == wind.size()) mx[3] = INF;
      |        ~~~~~~^~~~~~~~~~~~~~
virus.cpp: In function 'void readio()':
virus.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("input.txt", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
virus.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("output.txt", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...