-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1327B.cpp
38 lines (34 loc) · 900 Bytes
/
1327B.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
#define LL long long
#define mod 998244353
#define FOR(i, j, k) for (int i=j ; i<k ; i++)
#define ROF(i, j, k) for (int i=j ; i>=k ; i--)
const long long INF = 1e18;
const long long MAX = 1e5+10;
int main(){
fastio;
int t; cin>>t;
while(t--){
int n; cin>>n;
bool d[MAX]={false},k[MAX]={false};
FOR(i,1,n+1){
int x; cin>>x;
FOR(j,0,x) {int y; cin>>y;
if(d[i]) continue; if(!k[y]) {d[i]=true; k[y]=true;}
}
}
int x=0,y=0;
FOR(i,1,n+1) if(!d[i]){x=i; break;}
FOR(i,1,n+1) if(!k[i]){y=i; break;}
if(x && y){
cout<<"IMPROVE"<<"\n";
cout<<x<<" "<<y;
}
else {
cout<<"OPTIMAL";
}
cout<<"\n";
}
}