纯属练习JAVA....
import java.util.*; public class Main { public static void main(String[] args) { Scanner cin=new Scanner(System.in); int n=cin.nextInt(),m=cin.nextInt(),k=cin.nextInt(); String[] mp=new String[n]; for(int i=0;i<n;i++) mp[i]=cin.next(); int[] ans=new int[m]; for(int i=0;i<n;i++) { for(int j=0;j<m;j++) { char c=mp[i].charAt(j); if(c=='U') { if(i%2==0) ans[j]++; } else if(c=='R') { int t=i+j; if(t<m) ans[t]++; } else if(c=='L') { int t=j-i; if(t>=0) ans[t]++; } } } StringBuilder RET=new StringBuilder(); for(int i=0;i<m;i++) { RET.append(ans[i]+" "); } System.out.println(RET); } }