Submission #527725

#TimeUsernameProblemLanguageResultExecution timeMemory
5277258e7Sandcastle 2 (JOI22_ho_t5)C++17
10 / 100
3 ms716 KiB
//Challenge: Accepted #include <bits/stdc++.h> using namespace std; #ifdef zisk void debug(){cout << endl;} template<class T, class ... U> void debug(T a, U ... b){cout << a << " ", debug(b...);} template<class T> void pary(T l, T r) { while (l != r) cout << *l << " ", l++; cout << endl; } #else #define debug(...) 0 #define pary(...) 0 #endif #define ll long long #define maxn 105 #define pii pair<int, int> #define ff first #define ss second #define io ios_base::sync_with_stdio(0);cin.tie(0); int a[maxn][maxn]; int main() { io int n, m; cin >> n >> m; vector<int> val; for (int i = 0;i < n;i++) { for (int j = 0;j < m;j++) { cin >> a[i][j]; val.push_back(a[i][j]); } } sort(val.begin(), val.end()); val.resize(int(unique(val.begin(), val.end()) - val.begin())); for (int i = 0;i < n;i++) { for (int j = 0;j < m;j++) { a[i][j] = lower_bound(val.begin(), val.end(), a[i][j]) - val.begin(); } } if (n == 1) { ll ans = 0, cnt = 0; for (int i = 1;i < m;i++) { if (a[0][i] > a[0][i-1]) { cnt++; } else { cnt = 0; } ans += cnt; } cnt = 0; for (int i = m - 2;i >= 0;i--) { if (a[0][i] > a[0][i+1]) { cnt++; } else { cnt = 0; } ans += cnt; } ans += m; cout << ans << endl; } else { int ans = 0; for (int l = 0;l < n;l++) { for (int r = l;r < n;r++) { for (int u = 0;u < m;u++) { for (int d = u;d < m;d++) { vector<pair<int, pii> > val; for (int x = l;x <= r;x++) { for (int y = u;y <= d;y++) { val.push_back({a[x][y], make_pair(x, y)}); } } sort(val.begin(), val.end()); bool poss = 1; for (int i = 1;i < val.size();i++) { int xd = abs(val[i].ss.ff - val[i-1].ss.ff); int yd = abs(val[i].ss.ss - val[i-1].ss.ss); if (xd + yd > 1) { poss = 0; break; } } if (poss) ans++; } } } } cout << ans << "\n"; } }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:75:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   75 |       for (int i = 1;i < val.size();i++) {
      |                      ~~^~~~~~~~~~~~
#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...