# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1143143 | victor_c | 새로운 문제 (POI13_ins) | C++20 | 2 ms | 1352 KiB |
#include <iostream>
using namespace std;
bool mat[1005][1005], ok[1005];
int cnt[1005], others[1005];
int main()
{
int z, n, m, t, p, alt, c=0;
cin>>z;
for(int i=0; i<z; i++)
{
for(int j=0; j<1005; j++)
{
ok[j]=0;
cnt[j]=0;
others[j]=0;
for(int k=0; k<1005; k++)
{
mat[j][k]=0;
}
}
c=0;
cin>>n>>m;
for(int j=0; j<m; j++)
{
cin>>t>>p>>alt;
others[j]=alt;
if(ok[p]==1)
{
for(int k=t-1; k>0; k--)
{
if(mat[p][k]==1) break;
mat[p][k]=1;
cnt[k]++;
}
}
mat[p][t]=1;
ok[p]=1;
cnt[t]++;
for(int k=0; k<=j; k++)
{
if(cnt[k]>others[k]+1)
{
cout<<j<<endl;
c=1;
break;
}
}
if(c==1) break;
}
if(c==0) cout<<m<<endl;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |