Submission #930380

# Submission time Handle Problem Language Result Execution time Memory
930380 2024-02-19T13:51:18 Z vjudge1 Towers (NOI22_towers) C++17
0 / 100
2000 ms 9000 KB
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    pair<int,int> arr[n];
    map<int,int> x;
    map<int,int> y;
    for(int i = 0;i<n;i++)cin>>arr[i].first>>arr[i].second;
    int ans=0;
    int mx = 0;
    for(int mask = 1;mask< (1<<n);mask++){
        for(int i = 0;i<n;i++){x[arr[i].first]=0;y[arr[i].second]=0;}
        int cnt = 0;
        bool can = true;
        for(int i = 0;i<n;i++){
            if(!((1<<i)&mask))continue;
            cnt++;
            x[arr[i].first]++;
            y[arr[i].second]++;
            if(x[arr[i].first]>=3||y[arr[i].second]>=3){can=false;break;}
        }
        can&=(cnt>=2);
        bool stop = false;
        if(can){
        for(int i = 0;i<n;i++){
            if(!((1<<i)&mask))continue;
            // cnt++;
            if(!x[arr[i].first]||!y[arr[i].second]){stop=true;break;}
        }
            // if(mask==63)for(int i = 0;i<n;i++)cout<<arr[i].first<<" "<<x[arr[i].first]<<" "<<arr[i].second<<" "<<y[arr[i].second]<<endl;
            // cout<<mask<<" "<<cnt<<endl;
            if(cnt>mx&&!stop){
                mx=cnt;
                ans=mask;
            }
        }
    }
    for(int i = 0;i<n;i++){
            if(!((1<<i)&ans))cout<<0;
            else{
                cout<<1;
            }
        }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2041 ms 1148 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 454 ms 9000 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Halted 0 ms 0 KB -