QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#308229 | #5203. Easy Assembly | halfkhoonprince | WA | 2ms | 3800kb | C++14 | 4.1kb | 2024-01-19 19:24:46 | 2024-01-19 19:24:47 |
Judging History
answer
#include <bits/stdc++.h>
#include <cstdio>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
//#define ordered_set tree<long long, null_type,less<long long>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
#define fi first
#define se second
#define int long long
typedef pair<int, int> pi;
typedef vector<int> vi;
#define pb push_back
#define rep(i,a,b) for(int i = a; i < b; i++)
#define ld long double
#define all(x) x.begin(),x.end()
#define in(arr) for(int i = 0; i<arr.size(); i++) cin>>arr[i];
#define outs(arr) for(int i = 0; i<arr.size(); i++) cout<<arr[i]<<" ";
#define out(arr) for(int i = 0; i<arr.size(); i++) cout<<arr[i];
#define sqrt(x) sqrtl(x)
#define endl "\n"
#define read(x) int x; cin>>x;
#define sz(x) (int)(x).size()
void setIO(string name) { // name is nonempty for USACO file I/O
ios_base::sync_with_stdio(0);
cin.tie(0); // see Fast Input & Output
// alternatively, cin.tie(0)->sync_with_stdio(0);
if (sz(name)) {
freopen((name + ".in").c_str(), "r", stdin); // see Input & Output
freopen((name + ".out").c_str(), "w", stdout);
}
}
void fastIO(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
void yes(){
printf("YES\n");
}
void no(){
printf("NO\n");
}
int gcd(int a, int b) {
if (b == 0) {
return a;
}
return gcd(b, a % b);
}
int fact(int n){
if(n == 0){
return 1;
} else{
return n*fact(n-1);
}
}
void swap(int *a, int *b){
int temp = *a;
*a = *b;
*b = temp;
}
int nCr(int n, int r){
return fact(n)/(fact(n-r)*fact(r));
}
int max(int a, int b){
if(a>b){
return a;
} else{
return b;
}
}
bool check_pali(string s, int r){
vector<char> s1;
for(int i=r; i>=0; i++){
s1.push_back(s[i]);
}
for(int i=0; i<=r; i++){
if(s[i] == s1[i]){
continue;
} else{
return false;
}
}
return true;
}
// bool compfn(string s1, string s2){
// if(p1.second == p2.second){
// return p1.first < p2.first;
// } else{
// return p1.second > p2.second;
// }
// }
void dump(){
int n; cin>>n;
string a,b; cin>>a>>b;
bool notEqual = false;
rep(i,0,n){
if(notEqual && a[i] == b[i]){
no(); return;
}
if(a[i] != b[i]){
notEqual = true;
}
}
}
void solve(){
int n; cin>>n;
vector<vector<int> > vec;
multiset<int> st;
rep(i,0,n){
int k; cin>>k;
vector<int> temp(k);
rep(j,0,k){
cin>>temp[j];
st.insert(temp[j]);
}
vec.push_back(temp);
}
// for(auto arr : vec){
// for(auto it : arr){
// cout<<it<<" ";
// } cout<<endl;
// } cout<<endl;
// for(auto it : st){
// cout<<it<<" ";
// } cout<<endl;
int splits = 0;
rep(i,0,n){
//cout<<sz(vec[i])-1<<endl;
rep(j,0,sz(vec[i])-1){
//cout<<"check\n";
auto it = st.lower_bound(vec[i][j]);
//cout<<*it<<endl;
it++;
if(it == st.end()){
splits++;
it--;
st.erase(it);
} else{
if(*it != vec[i][j+1]){
splits++;
}
it--;
st.erase(it);
}
}
st.erase(vec[i][sz(vec[i])-1]);
}
int towers = splits + n;
cout<<splits<<" "<<splits + n - 1;
}
signed main(){
// #ifndef ONLINE_JUDGE
// freopen("input1.txt", "r", stdin);
// freopen("output2.txt", "w", stdout);
// #endif
// test case counter
int tt;
tt = 1;
//cin>>tt;
//fastIO();
while(tt--){
solve();
}
//cout<<"check\n";
//solve alternating current
//sol//
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3584kb
input:
2 3 3 5 8 2 9 2
output:
1 2
result:
ok 2 number(s): "1 2"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3780kb
input:
1 1 1
output:
0 0
result:
ok 2 number(s): "0 0"
Test #3:
score: 0
Accepted
time: 1ms
memory: 3780kb
input:
1 1 1000000000
output:
0 0
result:
ok 2 number(s): "0 0"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3720kb
input:
1 2 1 2
output:
0 0
result:
ok 2 number(s): "0 0"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3800kb
input:
1 2 1 3
output:
0 0
result:
ok 2 number(s): "0 0"
Test #6:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
1 2 2 3
output:
0 0
result:
ok 2 number(s): "0 0"
Test #7:
score: 0
Accepted
time: 0ms
memory: 3784kb
input:
1 2 2 1
output:
1 1
result:
ok 2 number(s): "1 1"
Test #8:
score: 0
Accepted
time: 0ms
memory: 3480kb
input:
1 2 3 1
output:
1 1
result:
ok 2 number(s): "1 1"
Test #9:
score: 0
Accepted
time: 1ms
memory: 3508kb
input:
1 2 1 1000000000
output:
0 0
result:
ok 2 number(s): "0 0"
Test #10:
score: 0
Accepted
time: 2ms
memory: 3580kb
input:
1 2 1000000000 1
output:
1 1
result:
ok 2 number(s): "1 1"
Test #11:
score: 0
Accepted
time: 0ms
memory: 3516kb
input:
1 10 469824905 571701214 23624320 688416005 50705647 146779011 168882039 274124876 425787403 398650749
output:
5 5
result:
ok 2 number(s): "5 5"
Test #12:
score: 0
Accepted
time: 1ms
memory: 3572kb
input:
1 10 531024457 257806065 278607414 751547170 817188083 606910175 154942408 982356354 910281308 835317020
output:
7 7
result:
ok 2 number(s): "7 7"
Test #13:
score: 0
Accepted
time: 1ms
memory: 3744kb
input:
1 10 294221243 787120441 70147219 86087312 141707343 65274729 331433884 57927999 757193855 238508732
output:
7 7
result:
ok 2 number(s): "7 7"
Test #14:
score: -100
Wrong Answer
time: 0ms
memory: 3748kb
input:
1 10 296094740 321802219 395888174 421441577 499796309 715358733 571294031 588654238 533108023 838379396
output:
3 3
result:
wrong answer 1st numbers differ - expected: '4', found: '3'