답안 #772307

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
772307 2023-07-03T23:39:04 Z tolbi Bob (COCI14_bob) C++17
120 / 120
832 ms 18000 KB
#pragma optimize("Bismillahirrahmanirrahim")
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█■█
//█─█─█▄─█▄─█─█─█─█
//Allahuekber
//ahmet23 orz...
//Sani buyuk Osman Pasa Plevneden cikmam diyor
//FatihSultanMehmedHan
//YavuzSultanSelimHan
//AbdulhamidHan
#define author tolbi
#include <bits/stdc++.h>
#define deci(x) int x;cin>>x;
#define decstr(x) string x;cin>>x;
#define int long long
#define vint(x) vector<int> x
#define endl '\n'
#define cinarr(x) for (auto &it : x) cin>>it;
#define coutarr(x) for (auto &it : x) cout<<it<<" ";cout<<endl;
#define sortarr(x) sort(x.begin(), x.end())
#define sortrarr(x) sort(x.rbegin(), x.rend())
#define revarr(x) reverse(x.begin(), x.rend())
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define tol(x) (1ll<<((int)(bi)))
#define det(x) cout<<"NO\0YES"+((!!x)*3)<<endl;
#define INF LONG_LONG_MAX
using namespace std;
const int MOD = 1e9+7;
mt19937 ayahya(chrono::high_resolution_clock().now().time_since_epoch().count());
int32_t main(){
	ios;
	int T = 1;
	if (!T) cin>>T;
	int tno = 0;
	while (T-(tno++)){
		deci(n);deci(m);
		int arr[1000][1000];
		for (int i = 0; i < n; ++i)
		{
			for (int j = 0; j < m; ++j)
			{
				cin>>arr[i][j];
			}
		}
		int mask[1000];
		int ans = 0;
		for (int l = 0; l < n; l++){
			for (int i = 0; i < m; i++){
				mask[i]=arr[l][i];
			}
			for (int r = l; r < n; r++){
				int crr = 0;
				for (int i = 0; i < m; i++){
					if (mask[i]!=arr[r][i]) mask[i]=-1;
					if (mask[i]==-1){
						ans+=crr*(crr+1)/2;
						crr=0;
					}
					else {
						if (i>0 && mask[i]==mask[i-1]){
							crr++;
						}
						else {
							ans+=crr*(crr+1)/2;
							crr=1;
						}
					}
				}
				ans+=crr*(crr+1)/2;
			}
		}
		cout<<ans<<endl;
	}
}

Compilation message

bob.cpp:1: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
    1 | #pragma optimize("Bismillahirrahmanirrahim")
      |
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 8160 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 8152 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 91 ms 8676 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 99 ms 9100 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 89 ms 9304 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 98 ms 9312 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 611 ms 14808 KB Output is correct
2 Correct 817 ms 10096 KB Output is correct
3 Correct 528 ms 10092 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 638 ms 18000 KB Output is correct
2 Correct 684 ms 10096 KB Output is correct
3 Correct 513 ms 10092 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 637 ms 17736 KB Output is correct
2 Correct 520 ms 10168 KB Output is correct
3 Correct 512 ms 10096 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 656 ms 17724 KB Output is correct
2 Correct 832 ms 10176 KB Output is correct
3 Correct 506 ms 10044 KB Output is correct