Submission #1002862

# Submission time Handle Problem Language Result Execution time Memory
1002862 2024-06-19T20:53:42 Z Cabralbonzao MalnaRISC (COI21_malnarisc) C++17
0 / 100
10 ms 860 KB
#include<bits/stdc++.h>
using namespace std;

#define N 110
#define INFLL 2000000000000000020
#define pb push_back

typedef long long ll;
typedef pair<ll,ll> pll;

bool mat[N][N];
bool blocked[N];
vector<pll>query[N*N];
vector<ll>ord;

void cria(ll n)
{
    ord.clear();
    ll i=0,r;
    while(i<n)
    {
        r=rand();
        r%=n-i;
        r++;
        ord.pb(r);
        i++;
    }
    return;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    ll n,ops,q=0,i,j,sz,a;

    cin >> n;
    ops=n*(n-1);
    for(i=1;i<=n;i++)
    {
        mat[i][i]=true;
    }
    while(ops)
    {
        for(i=1;i<=n;i++)
            blocked[i]=false;
        for(i=1;i<=n;i++)
        {
            if(blocked[i])
                continue;
            cria(n);
            for(a=0;a<n;a++)
            {
                j=ord[a];
                if(blocked[j] || mat[i][j])
                    continue;
                blocked[i]=true;
                blocked[j]=true;
                mat[i][j]=true;
                mat[j][i]=true;
                ops-=2;
                query[q].pb({i,j});
                break;
            }
        }
        q++;
    }    
    cout << q << endl;
    for(i=0;i<q;i++)
    {
        sz=(ll)(query[i].size());
        for(j=0;j<sz;j++)
        {
            cout << "CMPSWP R" << query[i][j].first << 
                          " R" << query[i][j].second << ((j==sz-1) ? '\n' : ' ');
        }
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 604 KB not sorted
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 604 KB Unexpected end of file - token expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 604 KB Unexpected end of file - token expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 600 KB Unexpected end of file - token expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 604 KB Unexpected end of file - token expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 600 KB Unexpected end of file - token expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 856 KB Unexpected end of file - token expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 860 KB Unexpected end of file - token expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 860 KB Unexpected end of file - token expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 856 KB Unexpected end of file - token expected
2 Halted 0 ms 0 KB -