Submission #773809

#TimeUsernameProblemLanguageResultExecution timeMemory
773809FilyaVirus Experiment (JOI19_virus)C++14
14 / 100
359 ms6384 KiB
//♥God will make a way♥ //#include <bits/stdc++.h> #define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <string> #include <algorithm> #include <cmath> #include <cstring> #include <cassert> #include <set> #include <map> #include <unordered_map> #include <vector> #include <stack> #include <queue> #include <iomanip> #include <bitset> #include <stdio.h> #include <climits> #include <numeric> using namespace std; //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> //using namespace __gnu_pbds; //template <typename T> //using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; /////////////////////define///////////////////// #define ci(x) if(x) cout << "YES" << '\n'; else cout << "NO" << '\n'; #define cii(x) if(check(x)) #define MOD 1000000007 #define MOD2 998244353 #define oo 1e9 #define ool 1e18L #define pii pair<int, int> #define pll pair<long long, long long> #define mii map<int, int> #define vi vector<int> #define vpi vector<pair<int, int>> #define vll vector <ll> #define ff first #define ss second #define mp make_pair #define ll long long #define ld long double #define pb push_back #define eb emplace_back #define pob pop_back #define lb lower_bound #define ub upper_bound #define bs binary_search #define sz(x) (int((x).size())) #define all(x) (x).begin(), (x).end() #define alll(x) (x), (x) + n #define clr(x) (x).clear(); #define fri(x) for(int i = 0; i < x; ++i) #define frj(x) for(int j = 0; j < x; ++j) #define frp(x) for(int p = 0; p < x; ++p) #define frr(a, b) for(int i = a; i < b; ++i) #define frrj(a, b) for(int j = a; j < b; ++j) #define fra(x) for(int i = 0; i < x; ++i) cin >> a[i]; #define frb(x) for(int i = 0; i < x; ++i) cin >> b[i]; #define frs(x) for(auto it = x.begin(); it != x.end(); ++it) #define fr(x) for(auto it : x) //el #define fastio ios_base::sync_with_stdio(false); cin.tie(0); #define dbg(x) cerr << #x << ": " << x << endl; #define ce(x) cout << x << endl; #define uniq(x) x.resize(unique(all(x)) - x.begin()); //make all one after sorting #define blt __builtin_popcount /////////////////////print array, vector, deque, set, multiset, pair, map ///////////////////// void print(long long t) {cerr << t;} void print(int t) {cerr << t;} void print(string t) {cerr << t;} void print(char t) {cerr << t;} void print(double t) {cerr << t;} void print(long double t) {cerr << t;} void print(unsigned long long t) {cerr << t;} template <class T, class V> void print(pair <T, V> p) {cerr << "{"; print(p.first); cerr << ","; print(p.second); cerr << "}";} template <class T, class V> void print(T v[],V n) {cerr << "["; for(int i = 0; i < n; i++) {print(v[i]); cerr << " "; } cerr << "]"; cout << endl;} template <class T> void print(vector <T> v) {cerr << "[ "; for (T i : v) {print(i); cerr << " ";} cerr << "]"; cout << endl;} template <class T> void print(set <T> v) {cerr << "[ "; for (T i : v) {print(i); cerr << " ";} cerr << "]"; cout << endl;} template <class T> void print(multiset <T> v) {cerr << "[ "; for (T i : v) {print(i); cerr << " ";} cerr << "]"; cout << endl;} template <class T> void print(stack <T> v) {cerr << "[ "; stack<T> s = v; while(s.size()) {T i = s.top(); print(i); s.pop(); cerr << " ";} cerr << "]"; cout << endl;} template <class T> void print(queue <T> v) {cerr << "[ "; queue<T> s = v; while(s.size()) {T i = s.front(); print(i); s.pop(); cerr << " ";} cerr << "]"; cout << endl;} template <class T> void print(deque <T> v) {cerr << "[ "; deque<T> s = v; while(s.size()) {T i = s.front(); print(i); s.pop_front(); cerr << " ";} cerr << "]"; cout << endl;} template <class T, class V> void print(map <T, V> v) {cerr << "[ "; for (auto i : v) {print(i); cerr << " ";} cerr << "]"; cout << endl;} template <class T, class V> void print(unordered_map <T, V> v) {cerr << "[ "; for (auto i : v) {print(i); cerr << " ";} cerr << "]"; cout << endl;} /////////////////////code///////////////////// int ans[805][805], a[805][805], s[100005], maxi[4], mx[4][4]; int main() { fastio; int n, r, c; cin >> n >> r >> c; string t; cin >> t; fri(r) frj(c) cin >> a[i][j]; fri(n) { if(t[i] == 'W') s[i] = 0; else if(t[i] == 'E') s[i] = 1; else if(t[i] == 'N') s[i] = 2; else t[i] = 3; } vpi v; v.eb(s[0], 1); frr(1, n) { if(s[i] == s[i-1]) v.back().ss++; else v.eb(s[i], 1); } for(pii p : v) maxi[p.ff] = max(maxi[p.ff], p.ss); if(s[0] == s[n-1]) { if(v.size() == 1) maxi[s[0]] = 1e9; else maxi[s[0]] = max(maxi[s[0]], v[0].ss + v.back().ss); } fri(v.size() - 1) { mx[v[i].ff][v[i+1].ff] = max(mx[v[i].ff][v[i+1].ff], v[i].ss + v[i+1].ss); } int mini = 1e9; fri(r) { frj(c) { if(!a[i][j]) continue; ans[i][j] = 1; for(int p = j + 1; p < c; p++) { if(!a[i][p] || a[i][p] > maxi[0]) break; ans[i][j]++; } for(int p = j - 1; p >= 0; --p) { if(!a[i][p] || a[i][p] > maxi[1]) break; ans[i][j]++; } mini = min(mini, ans[i][j]); } } int cnt = 0; fri(r) frj(c) if(ans[i][j] == mini) cnt++; cout << mini << endl; cout << cnt; return 0; }

Compilation message (stderr)

virus.cpp: In function 'int main()':
virus.cpp:56:33: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 | #define fri(x) for(int i = 0; i < x; ++i)
      |                               ~~^~~~~~~~~
   57 | #define frj(x) for(int j = 0; j < x; ++j)
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   58 | #define frp(x) for(int p = 0; p < x; ++p)
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   59 | #define frr(a, b) for(int i = a; i < b; ++i)
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   60 | #define frrj(a, b) for(int j = a; j < b; ++j)
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   61 | #define fra(x) for(int i = 0; i < x; ++i) cin >> a[i];
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   62 | #define frb(x) for(int i = 0; i < x; ++i) cin >> b[i];
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   63 | #define frs(x) for(auto it = x.begin(); it != x.end(); ++it)
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   64 | #define fr(x) for(auto it : x) //el
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   65 | #define fastio ios_base::sync_with_stdio(false); cin.tie(0);
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   66 | #define dbg(x) cerr << #x << ": " << x << endl;
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   67 | #define ce(x) cout << x << endl;
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
   68 | #define uniq(x) x.resize(unique(all(x)) - x.begin()); //make all one after sorting
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   69 | #define blt __builtin_popcount
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~   
   70 | /////////////////////print array, vector, deque, set, multiset, pair, map /////////////////////
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   71 | void print(long long t) {cerr << t;}
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   72 | void print(int t) {cerr << t;}
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~   
   73 | void print(string t) {cerr << t;}
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   74 | void print(char t) {cerr << t;}
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
   75 | void print(double t) {cerr << t;}
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   76 | void print(long double t) {cerr << t;}
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   77 | void print(unsigned long long t) {cerr << t;}
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   78 | template <class T, class V> void print(pair <T, V> p) {cerr << "{"; print(p.first); cerr << ","; print(p.second); cerr << "}";}
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   79 | template <class T, class V> void print(T v[],V n) {cerr << "["; for(int i = 0; i < n; i++) {print(v[i]); cerr << " "; } cerr << "]"; cout << endl;}
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   80 | template <class T> void print(vector <T> v) {cerr << "[ "; for (T i : v) {print(i); cerr << " ";} cerr << "]"; cout << endl;}
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   81 | template <class T> void print(set <T> v) {cerr << "[ "; for (T i : v) {print(i); cerr << " ";} cerr << "]"; cout << endl;}
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   82 | template <class T> void print(multiset <T> v) {cerr << "[ "; for (T i : v) {print(i); cerr << " ";} cerr << "]"; cout << endl;}
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   83 | template <class T> void print(stack <T> v) {cerr << "[ "; stack<T> s = v; while(s.size()) {T i = s.top(); print(i); s.pop(); cerr << " ";} cerr << "]"; cout << endl;}
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   84 | template <class T> void print(queue <T> v) {cerr << "[ "; queue<T> s = v; while(s.size()) {T i = s.front(); print(i); s.pop(); cerr << " ";} cerr << "]"; cout << endl;}
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   85 | template <class T> void print(deque <T> v) {cerr << "[ "; deque<T> s = v; while(s.size()) {T i = s.front(); print(i); s.pop_front(); cerr << " ";} cerr << "]"; cout << endl;}
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   86 | template <class T, class V> void print(map <T, V> v) {cerr << "[ "; for (auto i : v) {print(i); cerr << " ";} cerr << "]"; cout << endl;}
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   87 | template <class T, class V> void print(unordered_map <T, V> v) {cerr << "[ "; for (auto i : v) {print(i); cerr << " ";} cerr << "]"; cout << endl;}
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   88 | /////////////////////code/////////////////////
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   89 | int ans[805][805], a[805][805], s[100005], maxi[4], mx[4][4];
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   90 | int main() {
      | ~~~~~~~~~~~~                     
   91 |     fastio;
      |     ~~~~~~~                      
   92 |     int n, r, c; cin >> n >> r >> c;
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   93 |     string t; cin >> t;
      |     ~~~~~~~~~~~~~~~~~~~          
   94 |     fri(r)
      |     ~~~~~~                       
   95 |         frj(c)
      |         ~~~~~~                   
   96 |             cin >> a[i][j];
      |             ~~~~~~~~~~~~~~~      
   97 |     fri(n) {
      |     ~~~~~~~~                     
   98 |         if(t[i] == 'W') s[i] = 0;
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~
   99 |         else if(t[i] == 'E') s[i] = 1;
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  100 |         else if(t[i] == 'N') s[i] = 2;
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  101 |         else t[i] = 3;
      |         ~~~~~~~~~~~~~~           
  102 |     }
      |     ~                            
  103 |     vpi v;
      |     ~~~~~~                       
  104 |     v.eb(s[0], 1);
      |     ~~~~~~~~~~~~~~               
  105 |     frr(1, n) {
      |     ~~~~~~~~~~~                  
  106 |         if(s[i] == s[i-1]) v.back().ss++;
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  107 |         else v.eb(s[i], 1);
      |         ~~~~~~~~~~~~~~~~~~~      
  108 |     }
      |     ~                            
  109 |     for(pii p : v) maxi[p.ff] = max(maxi[p.ff], p.ss);
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  110 |     if(s[0] == s[n-1]) {
      |     ~~~~~~~~~~~~~~~~~~~~         
  111 |         if(v.size() == 1) maxi[s[0]] = 1e9;
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  112 |         else maxi[s[0]] = max(maxi[s[0]], v[0].ss + v.back().ss);
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  113 |     }
      |     ~                            
  114 |     fri(v.size() - 1) {
      |     ~~~~~~~~~~~~~~~~             
virus.cpp:114:5: note: in expansion of macro 'fri'
  114 |     fri(v.size() - 1) {
      |     ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...