217582026-01-13 19:20:14TaxiradioCseppkőbarlang (45 pont)cpp17Wrong answer 30/4525ms1176 KiB
// Source: https://usaco.guide/general/io

#include <algorithm>
#include <bits/stdc++.h>
using namespace std;

#define int int64_t

vector<array<int , 2>> d = {{-1 , 0} , {1 , 0} , {0 , -1} , {0 , 1}};
    vector<vector<int>> a;

void dfs(int x , int y){
    int o = a[x][y];
    a[x][y] = 0;
    for(auto [u , v] : d){
        if(a[x+u][y+v]!= 0 && a[x+u][y+v] >= o)dfs(x+u , y+v);
    }
}

int32_t main() {
    int n , m ; cin >> n >> m;
    a.resize(n+2 , vector<int> (m+2 , 0));
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            int x; cin >> x;
            a[i+1][j+1] = x;
        }
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            if(a[i][j] == 0)continue;
            int w = a[i][j];
            dfs(i , j);
            a[i][j] = w;
        }
    }
    vector<array<int , 2>> ans;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            if(a[i][j] != 0)ans.push_back({i , j});
        }
    }
    cout << ans.size() << endl;
    for(auto z:ans)cout << z[0] << " " << z[1] << "\n";
}
SubtaskSumTestVerdictTimeMemory
base30/45
1Accepted0/01ms316 KiB
2Wrong answer0/01ms316 KiB
3Accepted1/11ms316 KiB
4Accepted1/11ms316 KiB
5Accepted2/212ms1176 KiB
6Accepted2/212ms816 KiB
7Accepted2/212ms832 KiB
8Accepted2/21ms316 KiB
9Accepted2/21ms332 KiB
10Accepted3/318ms1068 KiB
11Accepted3/325ms1064 KiB
12Accepted3/319ms1000 KiB
13Accepted3/319ms988 KiB
14Accepted3/314ms1068 KiB
15Wrong answer0/314ms1076 KiB
16Wrong answer0/313ms1076 KiB
17Wrong answer0/314ms1076 KiB
18Wrong answer0/316ms1064 KiB
19Wrong answer0/314ms1056 KiB
20Accepted3/324ms1056 KiB