标签:style blog http color io os ar for sp
水题,极水,列举,但要小心哦,开始判断那用了个循环,居然从249变成了250,查找了好一会才明白,条件复用是有条件的,虽然代码看起来漂亮了,但结果不对,又有何用。
居然从第五层跳回第一层了,不知道为什么,呵呵:
/* ID: qq104801 LANG: C++ TASK: combo QQ:104804687 */ #include <iostream> #include <fstream> #include <cstring> #include <vector> #include <queue> #include <stack> #include <algorithm> #include <cmath> using namespace std; #define loop(i,n) for(int i=0;i<(n);i++) #define loop2(i,n) for(int i=1;i<=(n);i++) const int maxn=205; const int inf=1<<30; struct combo_key { int x,y,z; }key[2]; int n,ans; bool close(int a,int b) { if(abs(a-b)<=2)return true; if(abs(a-b)>=n-2)return true; return false; } void test() { freopen("combo.in","r",stdin); freopen("combo.out","w",stdout); cin>>n; loop(i,2) cin>>key[i].x>>key[i].y>>key[i].z; ans=0; loop2(i,n) loop2(j,n) loop2(k,n) if((close(i,key[0].x) && close(j,key[0].y) && close(k,key[0].z)) ||(close(i,key[1].x) && close(j,key[1].y) && close(k,key[1].z))) ans++; cout<<ans<<endl; } int main () { test(); return 0; }
test data:
USACO Training Grader Results 15 users online CHN/6 TWN/1 USA/8 USER: cn tom [qq104801] TASK: combo LANG: C++ Compiling... Compile: OK Executing... Test 1: TEST OK [0.005 secs, 3376 KB] Test 2: TEST OK [0.005 secs, 3376 KB] Test 3: TEST OK [0.008 secs, 3376 KB] Test 4: TEST OK [0.005 secs, 3376 KB] Test 5: TEST OK [0.005 secs, 3376 KB] Test 6: TEST OK [0.008 secs, 3376 KB] Test 7: TEST OK [0.008 secs, 3376 KB] Test 8: TEST OK [0.011 secs, 3376 KB] Test 9: TEST OK [0.008 secs, 3376 KB] Test 10: TEST OK [0.019 secs, 3376 KB] All tests OK. Your program (‘combo‘) produced all correct answers! This is your submission #2 for this problem. Congratulations! Here are the test data inputs: ------- test 1 [length 15 bytes] ---- 50 1 2 3 5 6 7 ------- test 2 [length 14 bytes] ---- 1 1 1 1 1 1 1 ------- test 3 [length 14 bytes] ---- 4 1 2 3 2 3 4 ------- test 4 [length 15 bytes] ---- 10 9 9 9 3 3 3 ------- test 5 [length 18 bytes] ---- 50 49 50 1 50 1 2 ------- test 6 [length 18 bytes] ---- 95 5 6 7 70 80 90 ------- test 7 [length 22 bytes] ---- 100 100 100 100 1 1 1 ------- test 8 [length 21 bytes] ---- 100 1 50 100 2 51 99 ------- test 9 [length 22 bytes] ---- 100 1 100 99 1 100 98 ------- test 10 [length 18 bytes] ---- 100 100 1 2 4 5 6 Keep up the good work! Thanks for your submission!
标签:style blog http color io os ar for sp
原文地址:http://www.cnblogs.com/dpblue/p/4004840.html