QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#766794#9557. TemperanceLiangsheng298#WA 0ms3748kbC++141.6kb2024-11-20 18:38:432024-11-20 18:38:51

Judging History

This is the latest submission verdict.

  • [2024-11-20 18:38:51]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3748kb
  • [2024-11-20 18:38:43]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline T read(){
    T x=0;char ch=getchar();bool fl=false;
    while(!isdigit(ch)){if(ch=='-')fl=true;ch=getchar();}
    while(isdigit(ch)){
        x=(x<<3)+(x<<1)+(ch^48);ch=getchar();
    }
    return fl?-x:x;
}
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);
#define LL long long
#define LD long double
#define read() read<int>()
const int maxn = 1e5 + 10;
int T,n,ans[maxn];
unordered_map<int,int> cnt[3];
int main(){
    FASTIO;
    cin>>T;
    while(T--){
        cin>>n;
        int x,y,z;
        for(int i=0;i<3;i++)cnt[i].clear();
        for(int i=1;i<=n;i++){
            ans[i]=0x3f3f3f3f;
            cin>>x>>y>>z;
            cnt[0][x]++;cnt[1][y]++;cnt[2][z]++;
        }
        vector<int> vec;
        for(auto t:cnt[0])vec.push_back(t.second);
        sort(vec.begin(),vec.end());
        int j=0,S=0;
        for(int i=1;i<=n;i++){
            while(j<vec.size() && i>vec[j])S+=vec[j],j++;
            ans[i]=min(ans[i],S);
        }
        vec.clear();
        for(auto t:cnt[1])vec.push_back(t.second);
        sort(vec.begin(),vec.end());
        j=0,S=0;
        for(int i=1;i<=n;i++){
            while(j<vec.size() && i>vec[j])S+=vec[j],j++;
            ans[i]=min(ans[i],S);
        }
        vec.clear();
        for(auto t:cnt[2])vec.push_back(t.second);
        sort(vec.begin(),vec.end());
        j=0,S=0;
        for(int i=1;i<=n;i++){
            while(j<vec.size() && i>vec[j])S+=vec[j],j++;
            ans[i]=min(ans[i],S);
        }
        for(int i=1;i<=n;i++)cout<<ans[i]<<' ';cout<<'\n';
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3580kb

input:

2
5
1 1 1
1 1 2
1 1 3
2 3 5
2 2 4
3
1 1 1
2 2 2
3 3 3

output:

0 0 2 5 5 
0 3 3 

result:

ok 8 numbers

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3748kb

input:

16
1
1 1 1
2
1 1 1
1 1 100000
3
1 1 1
1 1 100000
1 100000 1
4
1 1 1
1 1 100000
1 100000 1
1 100000 100000
5
1 1 1
1 1 100000
1 100000 1
1 100000 100000
100000 1 1
6
1 1 1
1 1 100000
1 100000 1
1 100000 100000
100000 1 1
100000 1 100000
7
1 1 1
1 1 100000
1 100000 1
1 100000 100000
100000 1 1
100000 ...

output:

0 
0 0 
0 0 0 
0 0 0 0 
0 0 1 1 5 
0 0 0 2 6 6 
0 0 0 3 7 7 7 
0 0 0 0 8 8 8 8 
0 
0 0 
0 0 0 
0 0 0 0 
0 0 1 1 5 
0 0 0 2 6 6 
0 0 0 3 7 7 7 
0 0 0 0 8 8 8 8 

result:

wrong answer 13th numbers differ - expected: '0', found: '1'