#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("popcnt")
#include<bits/stdc++.h>
#define int long long
#define quick ios::sync_with_stdio(0);cin.tie(0);
#define rep(x,a,b) for(int x=a;x<=b;x++)
#define repd(x,a,b) for(int x=a;x>=b;x--)
#define mp make_pair
#define eb emplace_back
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define lowbit(x) (x&-x)
#define sz(x) (int)(x.size())
using namespace std;
typedef pair<int,int> pii;
void debug(){
cerr<<"\n";
}
template<class T,class ...U>
void debug(T a,U ...b){
cout<<a<<" ",debug(b...);
}
const int N=1000+7;
const int INF=1e18;
vector<string> s[N];
void f(int x,bool fail){
int l=sz(s[x]);
rep(i,1,l-1){
if(s[x][i][0]=='?') s[x][i][0]=fail ? '-' : '+';
}
}
pii get(int x){
pii res=mp(0,0);
rep(i,1,sz(s[x])-1){
if(s[x][i][0]=='+') {
res.F++;
int num=0;
int l=sz(s[x][i]);
int pos=0;
rep(j,1,l-1){
if(s[x][i][j]=='/') {pos=j+1;break;}
num=num*10+s[x][i][j]-'0';
}
//debug("ok");return res;
res.S+=num*20*60;
num=0;
while(pos<l){
if(s[x][i][pos]==':'){
pos++;break;
}
num=num*10+s[x][i][pos++]-'0';
}
res.S+=num*60*60;
num=0;
while(pos<l){
if(s[x][i][pos]==':'){
pos++;break;
}
num=num*10+s[x][i][pos++]-'0';
}
res.S+=num*60;
while(pos<l){
num=num*10+s[x][i][pos++]-'0';
}
res.S+=num;
}
}
return res;
}
bool great(int a,int b){
pii p1=get(a);
pii p2=get(b);
//debug(a,b,"a,b",p1.F,p1.S,",",p2.F,p2.S);
if(p1.F!=p2.F) return p1.F>p2.F;
return p1.S<p2.S;
}
signed main(){
quick
int n,m;
cin>>n>>m;
rep(i,0,n){
s[i].resize(m+1);
rep(j,0,m) cin>>s[i][j];
}
int st=0;
rep(i,0,n-1){
if(s[i][0]==s[n][0]) st=i;
}
rep(i,0,n-1){
if(i==st){
f(i,true);
}
else f(i,false);
}
/*rep(i,0,n-1){
for(string s2:s[i]) cout<<s2<<" ";cout<<"\n";
}*/
//debug("ok");return 0;
int Win=0;
rep(i,0,n-1){
if(i==st) continue;
//debug(i,st,"i,st");
if(great(i,n)) Win++;
}
cout<<Win+1<<"\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Incorrect |
2 ms |
852 KB |
Output isn't correct |
3 |
Incorrect |
0 ms |
340 KB |
Output isn't correct |
4 |
Incorrect |
2 ms |
852 KB |
Output isn't correct |
5 |
Incorrect |
2 ms |
852 KB |
Output isn't correct |