NEERC 2014 took place in St. Petersburg, Barnaul, Tbilisi and Tashkent on December 6-7, 2014

来源:互联网 发布:httpclient post 数据 编辑:程序博客网 时间:2024/04/29 14:57


A. 

#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>using namespace std;int n, m;int main(){    freopen("alter.in", "r", stdin);    freopen("alter.out", "w", stdout);    while(~scanf("%d%d", &n, &m))    {        int ans ;        //if(n == 2)        ans = n / 2 + m / 2;        printf("%d\n", ans);        int f1 = 0, f2 = 0;        if(n & 1) f1 = 1;        if(m & 1) f2 = 1;        int i = 1, j = 1;        if(m & 1) i = 2;        if(n & 1) j = 2;        for( ; i <= m; i += 2)        {            printf("1 %d %d %d\n", i, n, i);        }        for( ; j <= n; j += 2)        {            printf("%d 1 %d %d\n", j, j, m);        }    }    return 0;}


B.

#include <algorithm>#include <iostream>#include <cstring>#include <cstdio>#include <cmath>using namespace std;const int MAXN = 1e5 + 10;struct Node {    double g, a, b, s;    int id;};Node node[MAXN];int n;double a, b, sa, sb;bool cmp1( const Node &a, const Node &b ) {    return a.a / a.b > b.a / b.b;}bool cmp2( const Node &a, const Node &b ) {    return a.id < b.id;}int main() {    freopen( "burrito.in", "r", stdin );    freopen( "burrito.out", "w", stdout );    scanf( "%d%lf%lf", &n, &a, &b );    sa = sb = 0;    for( int i = 0; i < n; ++i ) {        scanf( "%lf%lf%lf", &node[i].g, &node[i].a, &node[i].b );        node[i].s = 0.0; node[i].id = i;    }    sort( node, node + n, cmp1 );    for( int i = 0; i < n; ++i ) {        if( node[i].b == 0.0 ) {            sa += node[i].g * node[i].a;            node[i].s = node[i].g;            continue;        }        if( b >= node[i].g * node[i].b ) {            b -= node[i].g * node[i].b;            sa += node[i].g * node[i].a;            sb += node[i].g * node[i].b;            node[i].s = node[i].g;        } else {            double k = b / node[i].b;            b -= k * node[i].b;            sa += k * node[i].a;            sb += k * node[i].b;            node[i].s = k;        }        if( b == 0.0 ) break;    }    sort( node, node + n, cmp2 );    if( sa < a ) puts( "-1 -1" );    else {        printf( "%.10f %.10f\n%.10f", sa, sb, node[0].s );        for( int i = 1; i < n; ++i ) {            printf( " %.10f", node[i].s );        }        puts( "" );    }    return 0;}


J.

#include <cstdio>#include <vector>#include <cstring>#include <iostream>#include <algorithm>using namespace std;#define N 100char s[N];int a[N];int _hash[N];int m, n;bool flag, mark;int go[N];void dfs(int pos, int flag){    //cout << "pos: " << pos << endl;    if(mark) return ;    if(pos == m + 1)    {        for(int i = 1; i <= n; i++)            if(!_hash[i]) return;        mark = true;        memset(go, 0, sizeof go);        for(int i = 1; i <= n; i++)        {            //cout << i << " :  " << _hash[i] << endl;            go[_hash[i]] = i;        }        int cnt = 0;        for(int i = 1; i <= m; i++)        {            if(go[i])            {                ++cnt == n ? printf("%d\n", go[i]) : printf("%d ", go[i]);            }        }    }    if(flag)    {        int t = a[pos - 1] * 10 + a[pos];        if(t <= n)        {            if(_hash[t])                return;            _hash[t] = pos - 1;            dfs(pos + 1, 0);            _hash[t] = 0;        }    }    else    {        if(_hash[a[pos]])        {            dfs(pos + 1, 1);        }        else        {            dfs(pos + 1, 1);            _hash[a[pos]] = pos;            dfs(pos + 1, 0);            _hash[a[pos]] = 0;        }    }}int main(){    freopen("joke.in", "r", stdin);    freopen("joke.out", "w", stdout);    while(~scanf("%s", s + 1))    {        mark = false;        memset(_hash, 0, sizeof _hash);        m = strlen(s + 1);        for(int i = 1; i <= m; i++) a[i] = (s[i] - '0');        if(m > 9)           n = (m + 9) / 2;        else n = m;        dfs(0, 0);    }    return 0;}/*4111109876532*/

F.

#include <iostream>#include <cstring>#include <bitset>#include <cstdio>#include <vector>using namespace std;typedef long long LL;const int MAXN = 1000 + 10;bitset<MAXN> b[MAXN], c[MAXN];vector<int> ans;int a[MAXN];char str[1000];int m, f, n, q, uk;int getint( char c ) {    int ans = 0;    if( '0' <= c && c <= '9' ) return c - '0';    return c - 'a' + 10;}int main() {    freopen( "filter.in", "r", stdin );    freopen( "filter.out", "w", stdout );    scanf( "%d%d", &m, &f );    for( int i = 0; i < f; ++i ) scanf( "%d", a + i );    scanf( "%d", &n );    for( int i = 0; i < n; ++i ) {        scanf( "%s", str );        for( int j = 0; j < strlen( str ); ++j ) {            int tmp = getint( str[j] );            for( int k = 0; k < 4; ++k ) {                if( ( 1 << k ) & tmp ) {                    b[i][j * 4 + k] = 1;                }            }        }    }    scanf( "%d", &q );    for( int i = 0; i < q; ++i ) {        scanf( "%d", &uk );        for( int j = 0; j < f; ++j ) {            c[i][( ( LL )uk * a[j] ) % m] = 1;        }    }    for( int i = 0; i < n; ++i ) {        for( int j = 0; j < q; ++j ) {            if( ( b[i] & c[j] ) == c[j] ) {                ans.push_back( i );                break;            }        }    }    printf( "%d", ans.size() );    for( int i = 0; i < ans.size(); ++i ) {        printf( " %d", ans[i] );    }    return 0;}


0 0