# |
Author |
Problem |
Lang |
Verdict |
Time |
Memory |
Sent |
Judged |
|
45014931 |
Contestant:
ab_ |
1043D
- 38
|
C++14 (GCC 6-32)
|
Wrong answer on pretest 7
|
31 ms
|
884 KB
|
2018-10-28 20:04:08 |
2018-10-28 20:04:09 |
|
#include <bits/stdc++.h>
using namespace std;
int a[100001];
int b[100001];
bool f[100001];
int main(){
int n,m,i,j,x,p=0;
cin>>m>>n;
for(j=1; j<=m; ++j){
cin>>x;
a[x]=p;
p=x;
}
// for(j=1; j<=m; ++j) cout<<a[j]<<" . "; cout<<endl;
for(i=2; i<=n; ++i){
p=0;
for(j=1; j<=m; ++j){
cin>>x;
b[x]=p;
p=x;
}
//for(j=1; j<=m; ++j) cout<<b[j]<<" . "; cout<<endl;
for(j=1; j<=m; ++j)
if(a[j]!=b[j])
f[j]=1;
}
int s1=0,s=0;
for(j=2; j<=m; ++j){
if(!f[j])
++s1;
else
s+=s1*(s1+1)/2, s1=0;
}
s+=s1*(s1+1)/2;
cout<<s+m;
return 0;
}
Click to see test details